46#include "llvm/ADT/ArrayRef.h"
47#include "llvm/ADT/DenseSet.h"
48#include "llvm/ADT/SmallBitVector.h"
49#include "llvm/ADT/SmallPtrSet.h"
50#include "llvm/ADT/SmallString.h"
51#include "llvm/ADT/StringSwitch.h"
52#include "llvm/ADT/Twine.h"
53#include "llvm/ADT/iterator_range.h"
54#include "llvm/Support/Casting.h"
55#include "llvm/Support/Path.h"
56#include "llvm/Support/raw_ostream.h"
75 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
81 std::vector<Result> Results;
88 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
93 class ShadowMapEntry {
98 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector *> DeclOrVector;
102 unsigned SingleDeclIndex = 0;
105 ShadowMapEntry() =
default;
106 ShadowMapEntry(
const ShadowMapEntry &) =
delete;
107 ShadowMapEntry(ShadowMapEntry &&Move) { *
this = std::move(Move); }
108 ShadowMapEntry &operator=(
const ShadowMapEntry &) =
delete;
109 ShadowMapEntry &operator=(ShadowMapEntry &&Move) {
110 SingleDeclIndex =
Move.SingleDeclIndex;
111 DeclOrVector =
Move.DeclOrVector;
112 Move.DeclOrVector =
nullptr;
117 if (DeclOrVector.isNull()) {
120 SingleDeclIndex = Index;
124 if (
const NamedDecl *PrevND = dyn_cast<const NamedDecl *>(DeclOrVector)) {
127 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
128 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
133 cast<DeclIndexPairVector *>(DeclOrVector)
134 ->push_back(DeclIndexPair(ND, Index));
138 if (DeclIndexPairVector *Vec =
139 DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
147 iterator begin()
const;
148 iterator end()
const;
154 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
171 bool AllowNestedNameSpecifiers;
182 std::list<ShadowMap> ShadowMaps;
196 bool HasObjectTypeQualifiers;
208 void AdjustResultPriorityForDecl(Result &R);
210 void MaybeAddConstructorResults(Result R);
216 LookupFilter Filter =
nullptr)
217 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
219 HasObjectTypeQualifiers(
false), CompletionContext(CompletionContext),
220 ObjCImplementation(nullptr) {
223 switch (CompletionContext.
getKind()) {
231 if (Method->isInstanceMethod())
233 ObjCImplementation =
Interface->getImplementation();
246 bool includeCodePatterns()
const {
252 void setFilter(LookupFilter Filter) { this->Filter =
Filter; }
254 Result *data() {
return Results.empty() ? nullptr : &Results.front(); }
255 unsigned size()
const {
return Results.size(); }
256 bool empty()
const {
return Results.empty(); }
271 ObjectTypeQualifiers = Quals;
273 HasObjectTypeQualifiers =
true;
281 void setPreferredSelector(
Selector Sel) { PreferredSelector = Sel; }
286 return CompletionContext;
290 void allowNestedNameSpecifiers(
bool Allow =
true) {
291 AllowNestedNameSpecifiers = Allow;
296 Sema &getSema()
const {
return SemaRef; }
310 bool isInterestingDecl(
const NamedDecl *ND,
311 bool &AsNestedNameSpecifier)
const;
336 bool CheckHiddenResult(Result &R,
DeclContext *CurContext,
346 void MaybeAddResult(Result R,
DeclContext *CurContext =
nullptr);
363 bool InBaseClass,
QualType BaseExprType);
366 void AddResult(Result R);
369 void EnterNewScope();
388 bool IsOrdinaryName(
const NamedDecl *ND)
const;
389 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
390 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
391 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
392 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
394 bool IsClassOrStruct(
const NamedDecl *ND)
const;
396 bool IsNamespace(
const NamedDecl *ND)
const;
397 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
399 bool IsMember(
const NamedDecl *ND)
const;
400 bool IsObjCIvar(
const NamedDecl *ND)
const;
401 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
402 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
403 bool IsObjCCollection(
const NamedDecl *ND)
const;
404 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
414 ComputeType =
nullptr;
415 Type = BSI->ReturnType;
419 ComputeType =
nullptr;
422 }
else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(S.
CurContext)) {
423 ComputeType =
nullptr;
424 Type = Method->getReturnType();
432 auto *VD = llvm::dyn_cast_or_null<ValueDecl>(
D);
433 ComputeType =
nullptr;
445 ComputeType =
nullptr;
454 this->ComputeType = ComputeType;
464 if (ExpectedLoc == LParLoc)
475 if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
478 if (Op == tok::minus)
491 case tok::minusequal:
493 case tok::percentequal:
495 case tok::slashequal:
501 case tok::equalequal:
502 case tok::exclaimequal:
506 case tok::greaterequal:
510 case tok::greatergreater:
511 case tok::greatergreaterequal:
513 case tok::lesslessequal:
526 case tok::caretequal:
534 case tok::periodstar:
562 case tok::minusminus:
572 assert(
false &&
"unhandled unary op");
581 ComputeType =
nullptr;
588 if (!Enabled || !
Base)
591 if (ExpectedLoc !=
Base->getBeginLoc())
602 ComputeType =
nullptr;
611 ComputeType =
nullptr;
620 ComputeType =
nullptr;
628 ComputeType =
nullptr;
634 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
635 unsigned SingleDeclIndex;
655 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) {}
658 : DeclOrIterator(Iterator), SingleDeclIndex(0) {}
661 if (isa<const NamedDecl *>(DeclOrIterator)) {
667 const DeclIndexPair *I = cast<const DeclIndexPair *>(DeclOrIterator);
683 return *cast<const DeclIndexPair *>(DeclOrIterator);
689 return X.DeclOrIterator.getOpaqueValue() ==
690 Y.DeclOrIterator.getOpaqueValue() &&
691 X.SingleDeclIndex == Y.SingleDeclIndex;
700ResultBuilder::ShadowMapEntry::begin()
const {
701 if (DeclOrVector.isNull())
704 if (
const NamedDecl *ND = dyn_cast<const NamedDecl *>(DeclOrVector))
705 return iterator(ND, SingleDeclIndex);
707 return iterator(cast<DeclIndexPairVector *>(DeclOrVector)->begin());
711ResultBuilder::ShadowMapEntry::end()
const {
712 if (isa<const NamedDecl *>(DeclOrVector) || DeclOrVector.isNull())
715 return iterator(cast<DeclIndexPairVector *>(DeclOrVector)->end());
736 for (
const DeclContext *CommonAncestor = TargetContext;
737 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
738 CommonAncestor = CommonAncestor->getLookupParent()) {
739 if (CommonAncestor->isTransparentContext() ||
740 CommonAncestor->isFunctionOrMethod())
743 TargetParents.push_back(CommonAncestor);
747 while (!TargetParents.empty()) {
750 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(
Parent)) {
751 if (!Namespace->getIdentifier())
755 }
else if (
const auto *TD = dyn_cast<TagDecl>(
Parent))
786bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
787 bool &AsNestedNameSpecifier)
const {
788 AsNestedNameSpecifier =
false;
803 if (isa<ClassTemplateSpecializationDecl>(ND) ||
804 isa<ClassTemplatePartialSpecializationDecl>(ND))
808 if (isa<UsingDecl>(ND))
814 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
815 (isa<NamespaceDecl>(ND) && Filter != &ResultBuilder::IsNamespace &&
816 Filter != &ResultBuilder::IsNamespaceOrAlias && Filter !=
nullptr))
817 AsNestedNameSpecifier =
true;
820 if (Filter && !(this->*Filter)(Named)) {
822 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
823 IsNestedNameSpecifier(ND) &&
824 (Filter != &ResultBuilder::IsMember ||
825 (isa<CXXRecordDecl>(ND) &&
826 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
827 AsNestedNameSpecifier =
true;
857 R.QualifierIsInformative =
false;
861 R.Declaration->getDeclContext());
870 switch (cast<BuiltinType>(
T)->
getKind()) {
871 case BuiltinType::Void:
874 case BuiltinType::NullPtr:
877 case BuiltinType::Overload:
878 case BuiltinType::Dependent:
881 case BuiltinType::ObjCId:
882 case BuiltinType::ObjCClass:
883 case BuiltinType::ObjCSel:
896 case Type::BlockPointer:
899 case Type::LValueReference:
900 case Type::RValueReference:
903 case Type::ConstantArray:
904 case Type::IncompleteArray:
905 case Type::VariableArray:
906 case Type::DependentSizedArray:
909 case Type::DependentSizedExtVector:
911 case Type::ExtVector:
914 case Type::FunctionProto:
915 case Type::FunctionNoProto:
924 case Type::ObjCObject:
925 case Type::ObjCInterface:
926 case Type::ObjCObjectPointer:
939 if (
const auto *
Type = dyn_cast<TypeDecl>(ND))
940 return C.getTypeDeclType(
Type);
941 if (
const auto *Iface = dyn_cast<ObjCInterfaceDecl>(ND))
942 return C.getObjCInterfaceType(Iface);
947 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND))
948 T = Method->getSendResultType();
949 else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND))
950 T =
C.getTypeDeclType(cast<EnumDecl>(Enumerator->getDeclContext()));
951 else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND))
953 else if (
const auto *
Value = dyn_cast<ValueDecl>(ND))
969 if (
Pointer->getPointeeType()->isFunctionType()) {
978 T =
Block->getPointeeType();
993unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
1001 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
1002 if (ImplicitParam->getIdentifier() &&
1003 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
1010 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC)) {
1012 if (isa<CXXDestructorDecl>(ND))
1024 if (isa<EnumConstantDecl>(ND))
1030 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
1032 CompletionContext.
getKind() ==
1034 CompletionContext.
getKind() ==
1041void ResultBuilder::AdjustResultPriorityForDecl(
Result &R) {
1044 if (!PreferredSelector.
isNull())
1045 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
1046 if (PreferredSelector == Method->getSelector())
1051 if (!PreferredType.
isNull()) {
1061 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
1073 return Record->lookup(ConstructorName);
1076void ResultBuilder::MaybeAddConstructorResults(
Result R) {
1077 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
1084 Record = ClassTemplate->getTemplatedDecl();
1085 else if ((
Record = dyn_cast<CXXRecordDecl>(
D))) {
1087 if (isa<ClassTemplateSpecializationDecl>(
Record))
1099 R.Declaration = Ctor;
1101 Results.push_back(R);
1106 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
1107 ND = Tmpl->getTemplatedDecl();
1108 return isa<CXXConstructorDecl>(ND);
1112 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
1114 if (R.Kind != Result::RK_Declaration) {
1116 Results.push_back(R);
1121 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1123 getBasePriority(
Using->getTargetDecl()),
1127 std::move(R.FixIts));
1129 MaybeAddResult(
Result, CurContext);
1136 bool AsNestedNameSpecifier =
false;
1137 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1144 ShadowMap &
SMap = ShadowMaps.back();
1145 ShadowMapEntry::iterator I, IEnd;
1146 ShadowMap::iterator NamePos =
SMap.find(R.Declaration->getDeclName());
1147 if (NamePos !=
SMap.end()) {
1148 I = NamePos->second.begin();
1149 IEnd = NamePos->second.end();
1152 for (; I != IEnd; ++I) {
1154 unsigned Index = I->second;
1157 Results[Index].Declaration = R.Declaration;
1167 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
1169 for (
SM = ShadowMaps.begin();
SM != SMEnd; ++
SM) {
1170 ShadowMapEntry::iterator I, IEnd;
1171 ShadowMap::iterator NamePos =
SM->find(R.Declaration->getDeclName());
1172 if (NamePos !=
SM->end()) {
1173 I = NamePos->second.begin();
1174 IEnd = NamePos->second.end();
1176 for (; I != IEnd; ++I) {
1178 if (I->first->hasTagIdentifierNamespace() &&
1186 I->first->getIdentifierNamespace() != IDNS)
1190 if (CheckHiddenResult(R, CurContext, I->first))
1198 if (!AllDeclsFound.insert(CanonDecl).second)
1203 if (AsNestedNameSpecifier) {
1204 R.StartsNestedNameSpecifier =
true;
1207 AdjustResultPriorityForDecl(R);
1210 if (R.QualifierIsInformative && !R.Qualifier &&
1211 !R.StartsNestedNameSpecifier) {
1212 const DeclContext *Ctx = R.Declaration->getDeclContext();
1213 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1216 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1218 SemaRef.
Context,
nullptr,
false,
1221 R.QualifierIsInformative =
false;
1226 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
1227 Results.push_back(R);
1229 if (!AsNestedNameSpecifier)
1230 MaybeAddConstructorResults(R);
1250 return OverloadCompare::BothViable;
1255 return OverloadCompare::BothViable;
1257 if (Candidate.
parameters()[I]->getType().getCanonicalType() !=
1258 Incumbent.
parameters()[I]->getType().getCanonicalType())
1259 return OverloadCompare::BothViable;
1262 return OverloadCompare::BothViable;
1267 if (CandidateRef != IncumbentRef) {
1274 return CandidateRef ==
RQ_RValue ? OverloadCompare::Dominates
1275 : OverloadCompare::Dominated;
1283 if (CandidateSuperset == IncumbentSuperset)
1284 return OverloadCompare::BothViable;
1285 return IncumbentSuperset ? OverloadCompare::Dominates
1286 : OverloadCompare::Dominated;
1289bool ResultBuilder::canCxxMethodBeCalled(
const CXXMethodDecl *Method,
1295 const auto *CurrentClassScope = [&]() ->
const CXXRecordDecl * {
1297 const auto *CtxMethod = llvm::dyn_cast<CXXMethodDecl>(Ctx);
1298 if (CtxMethod && !CtxMethod->getParent()->isLambda()) {
1299 return CtxMethod->getParent();
1306 bool FunctionCanBeCall =
1307 CurrentClassScope &&
1308 (CurrentClassScope == Method->
getParent() ||
1312 if (FunctionCanBeCall)
1317 BaseExprType.
isNull() ?
nullptr
1321 MaybeDerived == MaybeBase || MaybeDerived->
isDerivedFrom(MaybeBase);
1324 return FunctionCanBeCall;
1327bool ResultBuilder::canFunctionBeCalled(
const NamedDecl *ND,
1338 if (
const auto *FuncTmpl = dyn_cast<FunctionTemplateDecl>(ND)) {
1339 ND = FuncTmpl->getTemplatedDecl();
1341 const auto *Method = dyn_cast<CXXMethodDecl>(ND);
1342 if (Method && !Method->
isStatic()) {
1343 return canCxxMethodBeCalled(Method, BaseExprType);
1350 NamedDecl *Hiding,
bool InBaseClass =
false,
1352 if (R.Kind != Result::RK_Declaration) {
1354 Results.push_back(R);
1359 if (
const auto *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1361 getBasePriority(
Using->getTargetDecl()),
1365 std::move(R.FixIts));
1367 AddResult(
Result, CurContext, Hiding,
false,
1372 bool AsNestedNameSpecifier =
false;
1373 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1380 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
1384 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
1389 if (AsNestedNameSpecifier) {
1390 R.StartsNestedNameSpecifier =
true;
1392 }
else if (Filter == &ResultBuilder::IsMember && !R.Qualifier &&
1395 R.Declaration->getDeclContext()->getRedeclContext()))
1396 R.QualifierIsInformative =
true;
1399 if (R.QualifierIsInformative && !R.Qualifier &&
1400 !R.StartsNestedNameSpecifier) {
1401 const DeclContext *Ctx = R.Declaration->getDeclContext();
1402 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1405 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1407 SemaRef.
Context,
nullptr,
false,
1410 R.QualifierIsInformative =
false;
1417 AdjustResultPriorityForDecl(R);
1419 if (HasObjectTypeQualifiers)
1420 if (
const auto *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1423 if (ObjectTypeQualifiers == MethodQuals)
1425 else if (ObjectTypeQualifiers - MethodQuals) {
1447 auto &OverloadSet = OverloadMap[std::make_pair(
1449 for (
const DeclIndexPair Entry : OverloadSet) {
1450 Result &Incumbent = Results[Entry.second];
1452 *cast<CXXMethodDecl>(Incumbent.Declaration),
1453 ObjectTypeQualifiers, ObjectKind,
1455 case OverloadCompare::Dominates:
1459 Incumbent = std::move(R);
1461 case OverloadCompare::Dominated:
1464 case OverloadCompare::BothViable:
1468 OverloadSet.Add(Method, Results.size());
1471 R.FunctionCanBeCall = canFunctionBeCalled(R.getDeclaration(), BaseExprType);
1474 Results.push_back(R);
1476 if (!AsNestedNameSpecifier)
1477 MaybeAddConstructorResults(R);
1480void ResultBuilder::AddResult(
Result R) {
1481 assert(R.Kind != Result::RK_Declaration &&
1482 "Declaration results need more context");
1483 Results.push_back(R);
1487void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1490void ResultBuilder::ExitScope() {
1491 ShadowMaps.pop_back();
1496bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1505 if (isa<ObjCIvarDecl>(ND))
1514bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1516 if (isa<TypeDecl>(ND))
1521 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1522 if (!
ID->getDefinition())
1530 if (isa<ObjCIvarDecl>(ND))
1537bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1538 if (!IsOrdinaryNonTypeName(ND))
1542 if (VD->getType()->isIntegralOrEnumerationType())
1550bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1558 !isa<FunctionTemplateDecl>(ND) && !isa<ObjCPropertyDecl>(ND);
1563bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1565 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1566 ND = ClassTemplate->getTemplatedDecl();
1572bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1573 return isa<EnumDecl>(ND);
1577bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1579 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1580 ND = ClassTemplate->getTemplatedDecl();
1583 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1592bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1594 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1595 ND = ClassTemplate->getTemplatedDecl();
1597 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1604bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1605 return isa<NamespaceDecl>(ND);
1610bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1615bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1617 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1623bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1625 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1626 isa<ObjCPropertyDecl>(ND);
1630 T =
C.getCanonicalType(
T);
1632 case Type::ObjCObject:
1633 case Type::ObjCInterface:
1634 case Type::ObjCObjectPointer:
1638 switch (cast<BuiltinType>(
T)->
getKind()) {
1639 case BuiltinType::ObjCId:
1640 case BuiltinType::ObjCClass:
1641 case BuiltinType::ObjCSel:
1653 if (!
C.getLangOpts().CPlusPlus)
1662bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1671bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1673 if (IsObjCMessageReceiver(ND))
1676 const auto *Var = dyn_cast<VarDecl>(ND);
1680 return Var->hasLocalStorage() && !Var->hasAttr<BlocksAttr>();
1683bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1684 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1685 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1698bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1704bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1705 return isa<ObjCIvarDecl>(ND);
1713 ResultBuilder &Results;
1719 std::vector<FixItHint> FixIts;
1722 CodeCompletionDeclConsumer(
1723 ResultBuilder &Results,
DeclContext *InitialLookupCtx,
1725 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1726 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1727 FixIts(
std::move(FixIts)) {
1728 NamingClass = llvm::dyn_cast<CXXRecordDecl>(InitialLookupCtx);
1731 auto ThisType = Results.getSema().getCurrentThisType();
1732 if (!ThisType.isNull()) {
1733 assert(ThisType->isPointerType());
1739 this->BaseType = BaseType;
1743 bool InBaseClass)
override {
1746 Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass, BaseType);
1750 Results.addVisitedContext(Ctx);
1759 auto *NamingClass = this->NamingClass;
1760 QualType BaseType = this->BaseType;
1761 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1776 NamingClass =
nullptr;
1779 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1786 ResultBuilder &Results) {
1813 Results.getCodeCompletionTUInfo());
1814 if (LangOpts.CPlusPlus) {
1822 Builder.AddTypedTextChunk(
"typename");
1824 Builder.AddPlaceholderChunk(
"name");
1825 Results.AddResult(
Result(Builder.TakeString()));
1827 if (LangOpts.CPlusPlus11) {
1832 Builder.AddTypedTextChunk(
"decltype");
1834 Builder.AddPlaceholderChunk(
"expression");
1836 Results.AddResult(
Result(Builder.TakeString()));
1839 if (LangOpts.Char8 || LangOpts.CPlusPlus20)
1845 if (LangOpts.GNUKeywords) {
1851 Builder.AddTypedTextChunk(
"typeof");
1853 Builder.AddPlaceholderChunk(
"expression");
1854 Results.AddResult(
Result(Builder.TakeString()));
1856 Builder.AddTypedTextChunk(
"typeof");
1858 Builder.AddPlaceholderChunk(
"type");
1860 Results.AddResult(
Result(Builder.TakeString()));
1871 const LangOptions &LangOpts, ResultBuilder &Results) {
1876 Results.AddResult(
Result(
"extern"));
1877 Results.AddResult(
Result(
"static"));
1879 if (LangOpts.CPlusPlus11) {
1884 Builder.AddTypedTextChunk(
"alignas");
1886 Builder.AddPlaceholderChunk(
"expression");
1888 Results.AddResult(
Result(Builder.TakeString()));
1890 Results.AddResult(
Result(
"constexpr"));
1891 Results.AddResult(
Result(
"thread_local"));
1894 if (LangOpts.CPlusPlus20)
1895 Results.AddResult(
Result(
"constinit"));
1900 const LangOptions &LangOpts, ResultBuilder &Results) {
1905 if (LangOpts.CPlusPlus) {
1906 Results.AddResult(
Result(
"explicit"));
1907 Results.AddResult(
Result(
"friend"));
1908 Results.AddResult(
Result(
"mutable"));
1909 Results.AddResult(
Result(
"virtual"));
1917 if (LangOpts.CPlusPlus || LangOpts.C99)
1918 Results.AddResult(
Result(
"inline"));
1920 if (LangOpts.CPlusPlus20)
1921 Results.AddResult(
Result(
"consteval"));
1941 ResultBuilder &Results,
bool NeedAt);
1943 ResultBuilder &Results,
bool NeedAt);
1945 ResultBuilder &Results,
bool NeedAt);
1950 Results.getCodeCompletionTUInfo());
1951 Builder.AddTypedTextChunk(
"typedef");
1953 Builder.AddPlaceholderChunk(
"type");
1955 Builder.AddPlaceholderChunk(
"name");
1962 ResultBuilder &Results) {
1963 Builder.AddTypedTextChunk(
"using");
1965 Builder.AddPlaceholderChunk(
"name");
1967 Builder.AddPlaceholderChunk(
"type");
1990 return LangOpts.CPlusPlus;
1997 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
2000 llvm_unreachable(
"Invalid ParserCompletionContext!");
2027 if (!
T.getLocalQualifiers()) {
2030 return BT->getNameAsCString(Policy);
2033 if (
const TagType *TagT = dyn_cast<TagType>(
T))
2034 if (
TagDecl *Tag = TagT->getDecl())
2035 if (!Tag->hasNameForLinkage()) {
2036 switch (Tag->getTagKind()) {
2038 return "struct <anonymous>";
2040 return "__interface <anonymous>";
2042 return "class <anonymous>";
2044 return "union <anonymous>";
2046 return "enum <anonymous>";
2053 T.getAsStringInternal(
Result, Policy);
2054 return Allocator.CopyString(
Result);
2066 Builder.AddResultTypeChunk(
2068 Builder.AddTypedTextChunk(
"this");
2073 ResultBuilder &Results,
2075 if (!LangOpts.CPlusPlus11)
2078 Builder.AddTypedTextChunk(
"static_assert");
2080 Builder.AddPlaceholderChunk(
"expression");
2082 Builder.AddPlaceholderChunk(
"message");
2091 Sema &S = Results.getSema();
2092 const auto *CR = llvm::dyn_cast<CXXRecordDecl>(S.
CurContext);
2098 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
2099 for (
auto *Method : CR->methods()) {
2102 Overrides[Method->
getName()].push_back(Method);
2105 for (
const auto &
Base : CR->bases()) {
2106 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
2109 for (
auto *Method : BR->methods()) {
2112 const auto it = Overrides.find(Method->
getName());
2113 bool IsOverriden =
false;
2114 if (it != Overrides.end()) {
2115 for (
auto *MD : it->second) {
2133 false, CCContext, Policy);
2143 Scope *S,
Sema &SemaRef, ResultBuilder &Results) {
2151 if (Results.includeCodePatterns()) {
2153 Builder.AddTypedTextChunk(
"namespace");
2155 Builder.AddPlaceholderChunk(
"identifier");
2159 Builder.AddPlaceholderChunk(
"declarations");
2162 Results.AddResult(
Result(Builder.TakeString()));
2166 Builder.AddTypedTextChunk(
"namespace");
2168 Builder.AddPlaceholderChunk(
"name");
2170 Builder.AddPlaceholderChunk(
"namespace");
2172 Results.AddResult(
Result(Builder.TakeString()));
2175 Builder.AddTypedTextChunk(
"using namespace");
2177 Builder.AddPlaceholderChunk(
"identifier");
2179 Results.AddResult(
Result(Builder.TakeString()));
2182 Builder.AddTypedTextChunk(
"asm");
2184 Builder.AddPlaceholderChunk(
"string-literal");
2186 Results.AddResult(
Result(Builder.TakeString()));
2188 if (Results.includeCodePatterns()) {
2190 Builder.AddTypedTextChunk(
"template");
2192 Builder.AddPlaceholderChunk(
"declaration");
2193 Results.AddResult(
Result(Builder.TakeString()));
2204 if (!CurrentModule) {
2206 Builder.AddTypedTextChunk(
"module");
2209 Results.AddResult(
Result(Builder.TakeString()));
2214 if (!CurrentModule ||
2219 Builder.AddTypedTextChunk(
"module");
2221 Builder.AddPlaceholderChunk(
"name");
2224 Results.AddResult(
Result(Builder.TakeString()));
2229 if (!CurrentModule ||
2233 Builder.AddTypedTextChunk(
"import");
2235 Builder.AddPlaceholderChunk(
"name");
2238 Results.AddResult(
Result(Builder.TakeString()));
2241 if (CurrentModule &&
2245 Builder.AddTypedTextChunk(
"module");
2248 Builder.AddTypedTextChunk(
"private");
2251 Results.AddResult(
Result(Builder.TakeString()));
2256 if (!CurrentModule ||
2271 Builder.AddTypedTextChunk(
"using");
2273 Builder.AddPlaceholderChunk(
"qualifier");
2274 Builder.AddTextChunk(
"::");
2275 Builder.AddPlaceholderChunk(
"name");
2277 Results.AddResult(
Result(Builder.TakeString()));
2284 Builder.AddTypedTextChunk(
"using typename");
2286 Builder.AddPlaceholderChunk(
"qualifier");
2287 Builder.AddTextChunk(
"::");
2288 Builder.AddPlaceholderChunk(
"name");
2290 Results.AddResult(
Result(Builder.TakeString()));
2298 bool IsNotInheritanceScope = !S->isClassInheritanceScope();
2300 Builder.AddTypedTextChunk(
"public");
2301 if (IsNotInheritanceScope && Results.includeCodePatterns())
2303 Results.AddResult(
Result(Builder.TakeString()));
2306 Builder.AddTypedTextChunk(
"protected");
2307 if (IsNotInheritanceScope && Results.includeCodePatterns())
2309 Results.AddResult(
Result(Builder.TakeString()));
2312 Builder.AddTypedTextChunk(
"private");
2313 if (IsNotInheritanceScope && Results.includeCodePatterns())
2315 Results.AddResult(
Result(Builder.TakeString()));
2333 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
2335 Builder.AddTypedTextChunk(
"template");
2337 Builder.AddPlaceholderChunk(
"parameters");
2339 Results.AddResult(
Result(Builder.TakeString()));
2377 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
2379 Builder.AddTypedTextChunk(
"try");
2383 Builder.AddPlaceholderChunk(
"statements");
2387 Builder.AddTextChunk(
"catch");
2390 Builder.AddPlaceholderChunk(
"declaration");
2395 Builder.AddPlaceholderChunk(
"statements");
2398 Results.AddResult(
Result(Builder.TakeString()));
2403 if (Results.includeCodePatterns()) {
2405 Builder.AddTypedTextChunk(
"if");
2409 Builder.AddPlaceholderChunk(
"condition");
2411 Builder.AddPlaceholderChunk(
"expression");
2416 Builder.AddPlaceholderChunk(
"statements");
2419 Results.AddResult(
Result(Builder.TakeString()));
2422 Builder.AddTypedTextChunk(
"switch");
2426 Builder.AddPlaceholderChunk(
"condition");
2428 Builder.AddPlaceholderChunk(
"expression");
2433 Builder.AddPlaceholderChunk(
"cases");
2436 Results.AddResult(
Result(Builder.TakeString()));
2443 Builder.AddTypedTextChunk(
"case");
2445 Builder.AddPlaceholderChunk(
"expression");
2447 Results.AddResult(
Result(Builder.TakeString()));
2450 Builder.AddTypedTextChunk(
"default");
2452 Results.AddResult(
Result(Builder.TakeString()));
2455 if (Results.includeCodePatterns()) {
2457 Builder.AddTypedTextChunk(
"while");
2461 Builder.AddPlaceholderChunk(
"condition");
2463 Builder.AddPlaceholderChunk(
"expression");
2468 Builder.AddPlaceholderChunk(
"statements");
2471 Results.AddResult(
Result(Builder.TakeString()));
2474 Builder.AddTypedTextChunk(
"do");
2478 Builder.AddPlaceholderChunk(
"statements");
2481 Builder.AddTextChunk(
"while");
2484 Builder.AddPlaceholderChunk(
"expression");
2486 Results.AddResult(
Result(Builder.TakeString()));
2489 Builder.AddTypedTextChunk(
"for");
2493 Builder.AddPlaceholderChunk(
"init-statement");
2495 Builder.AddPlaceholderChunk(
"init-expression");
2498 Builder.AddPlaceholderChunk(
"condition");
2501 Builder.AddPlaceholderChunk(
"inc-expression");
2506 Builder.AddPlaceholderChunk(
"statements");
2509 Results.AddResult(
Result(Builder.TakeString()));
2513 Builder.AddTypedTextChunk(
"for");
2516 Builder.AddPlaceholderChunk(
"range-declaration");
2519 Builder.AddTextChunk(
"in");
2523 Builder.AddPlaceholderChunk(
"range-expression");
2528 Builder.AddPlaceholderChunk(
"statements");
2531 Results.AddResult(
Result(Builder.TakeString()));
2535 if (S->getContinueParent()) {
2537 Builder.AddTypedTextChunk(
"continue");
2539 Results.AddResult(
Result(Builder.TakeString()));
2542 if (S->getBreakParent()) {
2544 Builder.AddTypedTextChunk(
"break");
2546 Results.AddResult(
Result(Builder.TakeString()));
2552 ReturnType =
Function->getReturnType();
2553 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
2559 Builder.AddTypedTextChunk(
"return");
2561 Results.AddResult(
Result(Builder.TakeString()));
2563 assert(!ReturnType.
isNull());
2565 Builder.AddTypedTextChunk(
"return");
2567 Builder.AddPlaceholderChunk(
"expression");
2569 Results.AddResult(
Result(Builder.TakeString()));
2572 Builder.AddTypedTextChunk(
"co_return");
2574 Builder.AddPlaceholderChunk(
"expression");
2576 Results.AddResult(
Result(Builder.TakeString()));
2580 Builder.AddTypedTextChunk(
"return true");
2582 Results.AddResult(
Result(Builder.TakeString()));
2584 Builder.AddTypedTextChunk(
"return false");
2586 Results.AddResult(
Result(Builder.TakeString()));
2591 Builder.AddTypedTextChunk(
"return nullptr");
2593 Results.AddResult(
Result(Builder.TakeString()));
2598 Builder.AddTypedTextChunk(
"goto");
2600 Builder.AddPlaceholderChunk(
"label");
2602 Results.AddResult(
Result(Builder.TakeString()));
2605 Builder.AddTypedTextChunk(
"using namespace");
2607 Builder.AddPlaceholderChunk(
"identifier");
2609 Results.AddResult(
Result(Builder.TakeString()));
2626 Builder.AddTypedTextChunk(
"__bridge");
2628 Builder.AddPlaceholderChunk(
"type");
2630 Builder.AddPlaceholderChunk(
"expression");
2631 Results.AddResult(
Result(Builder.TakeString()));
2634 Builder.AddTypedTextChunk(
"__bridge_transfer");
2636 Builder.AddPlaceholderChunk(
"Objective-C type");
2638 Builder.AddPlaceholderChunk(
"expression");
2639 Results.AddResult(
Result(Builder.TakeString()));
2642 Builder.AddTypedTextChunk(
"__bridge_retained");
2644 Builder.AddPlaceholderChunk(
"CF type");
2646 Builder.AddPlaceholderChunk(
"expression");
2647 Results.AddResult(
Result(Builder.TakeString()));
2658 Builder.AddResultTypeChunk(
"bool");
2659 Builder.AddTypedTextChunk(
"true");
2660 Results.AddResult(
Result(Builder.TakeString()));
2663 Builder.AddResultTypeChunk(
"bool");
2664 Builder.AddTypedTextChunk(
"false");
2665 Results.AddResult(
Result(Builder.TakeString()));
2669 Builder.AddTypedTextChunk(
"dynamic_cast");
2671 Builder.AddPlaceholderChunk(
"type");
2674 Builder.AddPlaceholderChunk(
"expression");
2676 Results.AddResult(
Result(Builder.TakeString()));
2680 Builder.AddTypedTextChunk(
"static_cast");
2682 Builder.AddPlaceholderChunk(
"type");
2685 Builder.AddPlaceholderChunk(
"expression");
2687 Results.AddResult(
Result(Builder.TakeString()));
2690 Builder.AddTypedTextChunk(
"reinterpret_cast");
2692 Builder.AddPlaceholderChunk(
"type");
2695 Builder.AddPlaceholderChunk(
"expression");
2697 Results.AddResult(
Result(Builder.TakeString()));
2700 Builder.AddTypedTextChunk(
"const_cast");
2702 Builder.AddPlaceholderChunk(
"type");
2705 Builder.AddPlaceholderChunk(
"expression");
2707 Results.AddResult(
Result(Builder.TakeString()));
2711 Builder.AddResultTypeChunk(
"std::type_info");
2712 Builder.AddTypedTextChunk(
"typeid");
2714 Builder.AddPlaceholderChunk(
"expression-or-type");
2716 Results.AddResult(
Result(Builder.TakeString()));
2720 Builder.AddTypedTextChunk(
"new");
2722 Builder.AddPlaceholderChunk(
"type");
2724 Builder.AddPlaceholderChunk(
"expressions");
2726 Results.AddResult(
Result(Builder.TakeString()));
2729 Builder.AddTypedTextChunk(
"new");
2731 Builder.AddPlaceholderChunk(
"type");
2733 Builder.AddPlaceholderChunk(
"size");
2736 Builder.AddPlaceholderChunk(
"expressions");
2738 Results.AddResult(
Result(Builder.TakeString()));
2741 Builder.AddResultTypeChunk(
"void");
2742 Builder.AddTypedTextChunk(
"delete");
2744 Builder.AddPlaceholderChunk(
"expression");
2745 Results.AddResult(
Result(Builder.TakeString()));
2748 Builder.AddResultTypeChunk(
"void");
2749 Builder.AddTypedTextChunk(
"delete");
2754 Builder.AddPlaceholderChunk(
"expression");
2755 Results.AddResult(
Result(Builder.TakeString()));
2759 Builder.AddResultTypeChunk(
"void");
2760 Builder.AddTypedTextChunk(
"throw");
2762 Builder.AddPlaceholderChunk(
"expression");
2763 Results.AddResult(
Result(Builder.TakeString()));
2770 Builder.AddResultTypeChunk(
"std::nullptr_t");
2771 Builder.AddTypedTextChunk(
"nullptr");
2772 Results.AddResult(
Result(Builder.TakeString()));
2775 Builder.AddResultTypeChunk(
"size_t");
2776 Builder.AddTypedTextChunk(
"alignof");
2778 Builder.AddPlaceholderChunk(
"type");
2780 Results.AddResult(
Result(Builder.TakeString()));
2783 Builder.AddResultTypeChunk(
"bool");
2784 Builder.AddTypedTextChunk(
"noexcept");
2786 Builder.AddPlaceholderChunk(
"expression");
2788 Results.AddResult(
Result(Builder.TakeString()));
2791 Builder.AddResultTypeChunk(
"size_t");
2792 Builder.AddTypedTextChunk(
"sizeof...");
2794 Builder.AddPlaceholderChunk(
"parameter-pack");
2796 Results.AddResult(
Result(Builder.TakeString()));
2801 Builder.AddTypedTextChunk(
"co_await");
2803 Builder.AddPlaceholderChunk(
"expression");
2804 Results.AddResult(
Result(Builder.TakeString()));
2807 Builder.AddTypedTextChunk(
"co_yield");
2809 Builder.AddPlaceholderChunk(
"expression");
2810 Results.AddResult(
Result(Builder.TakeString()));
2813 Builder.AddResultTypeChunk(
"bool");
2814 Builder.AddTypedTextChunk(
"requires");
2817 Builder.AddPlaceholderChunk(
"parameters");
2822 Builder.AddPlaceholderChunk(
"requirements");
2825 Results.AddResult(
Result(Builder.TakeString()));
2829 Builder.AddTypedTextChunk(
"requires");
2831 Builder.AddPlaceholderChunk(
"expression");
2833 Results.AddResult(
Result(Builder.TakeString()));
2843 if (ID->getSuperClass()) {
2844 std::string SuperType;
2845 SuperType = ID->getSuperClass()->getNameAsString();
2846 if (Method->isInstanceMethod())
2849 Builder.AddResultTypeChunk(Allocator.CopyString(SuperType));
2850 Builder.AddTypedTextChunk(
"super");
2851 Results.AddResult(
Result(Builder.TakeString()));
2860 Builder.AddResultTypeChunk(
"size_t");
2862 Builder.AddTypedTextChunk(
"alignof");
2864 Builder.AddTypedTextChunk(
"_Alignof");
2866 Builder.AddPlaceholderChunk(
"type");
2868 Results.AddResult(
Result(Builder.TakeString()));
2873 Builder.AddResultTypeChunk(
"nullptr_t");
2874 Builder.AddTypedTextChunk(
"nullptr");
2875 Results.AddResult(
Result(Builder.TakeString()));
2879 Builder.AddResultTypeChunk(
"size_t");
2880 Builder.AddTypedTextChunk(
"sizeof");
2882 Builder.AddPlaceholderChunk(
"expression-or-type");
2884 Results.AddResult(
Result(Builder.TakeString()));
2897 Results.AddResult(
Result(
"operator"));
2918 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2920 T = Method->getSendResultType(BaseType);
2923 }
else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2926 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2928 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2930 T = Ivar->getUsageType(BaseType);
2932 T = Ivar->getType();
2933 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
2935 }
else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND)) {
2945 Result.AddResultTypeChunk(
2952 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2953 if (Sentinel->getSentinel() == 0) {
2955 Result.AddTextChunk(
", nil");
2957 Result.AddTextChunk(
", NULL");
2959 Result.AddTextChunk(
", (void*)0");
2980 switch (*nullability) {
2990 Result +=
"null_unspecified ";
2994 llvm_unreachable(
"Not supported as a context-sensitive keyword!");
3011 bool SuppressBlock =
false) {
3017 if (!SuppressBlock) {
3020 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
3033 TL = AttrTL.getModifiedLoc();
3052 bool SuppressBlockName =
false,
bool SuppressBlock =
false,
3057 bool SuppressName =
false,
bool SuppressBlock =
false,
3065 if (
const auto *PVD = dyn_cast<ParmVarDecl>(Param))
3066 ObjCQual = PVD->getObjCDeclQualifier();
3067 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
3074 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
3081 if (ObjCMethodParam) {
3100 if (!
Block && ObjCMethodParam &&
3101 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
3102 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
3103 ->findPropertyDecl(
false))
3117 if (ObjCMethodParam) {
3122 if (
Result.back() !=
')')
3136 false, SuppressBlock,
3152 bool SuppressBlockName,
bool SuppressBlock,
3160 if (!ResultType->
isVoidType() || SuppressBlock)
3165 if (!BlockProto ||
Block.getNumParams() == 0) {
3172 for (
unsigned I = 0, N =
Block.getNumParams(); I != N; ++I) {
3185 if (SuppressBlock) {
3188 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3197 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3217 if (srcText.empty() || srcText ==
"=") {
3223 std::string DefValue(srcText.str());
3226 if (DefValue.at(0) !=
'=') {
3230 return " = " + DefValue;
3232 return " " + DefValue;
3241 bool InOptional =
false) {
3242 bool FirstParameter =
true;
3244 for (
unsigned P = Start, N =
Function->getNumParams();
P != N; ++
P) {
3251 Result.getCodeCompletionTUInfo());
3252 if (!FirstParameter)
3260 FirstParameter =
false;
3272 if (
Function->isVariadic() &&
P == N - 1)
3273 PlaceholderStr +=
", ...";
3276 Result.AddPlaceholderChunk(
3277 Result.getAllocator().CopyString(PlaceholderStr));
3281 if (Proto->isVariadic()) {
3282 if (Proto->getNumParams() == 0)
3283 Result.AddPlaceholderChunk(
"...");
3293 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false) {
3294 bool FirstParameter =
true;
3303 PEnd = Params->
begin() + MaxParameters;
3306 bool HasDefaultArg =
false;
3307 std::string PlaceholderStr;
3309 if (TTP->wasDeclaredWithTypename())
3310 PlaceholderStr =
"typename";
3311 else if (
const auto *TC = TTP->getTypeConstraint()) {
3312 llvm::raw_string_ostream OS(PlaceholderStr);
3313 TC->print(OS, Policy);
3315 PlaceholderStr =
"class";
3317 if (TTP->getIdentifier()) {
3318 PlaceholderStr +=
' ';
3319 PlaceholderStr += TTP->getIdentifier()->deuglifiedName();
3322 HasDefaultArg = TTP->hasDefaultArgument();
3324 dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
3325 if (NTTP->getIdentifier())
3326 PlaceholderStr = std::string(NTTP->getIdentifier()->deuglifiedName());
3327 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
3328 HasDefaultArg = NTTP->hasDefaultArgument();
3330 assert(isa<TemplateTemplateParmDecl>(*
P));
3335 PlaceholderStr =
"template<...> class";
3337 PlaceholderStr +=
' ';
3344 if (HasDefaultArg && !InDefaultArg) {
3348 Result.getCodeCompletionTUInfo());
3349 if (!FirstParameter)
3352 P - Params->
begin(),
true);
3357 InDefaultArg =
false;
3360 FirstParameter =
false;
3365 Result.AddPlaceholderChunk(
3366 Result.getAllocator().CopyString(PlaceholderStr));
3374 bool QualifierIsInformative,
3380 std::string PrintedNNS;
3382 llvm::raw_string_ostream OS(PrintedNNS);
3383 Qualifier->print(OS, Policy);
3385 if (QualifierIsInformative)
3386 Result.AddInformativeChunk(
Result.getAllocator().CopyString(PrintedNNS));
3388 Result.AddTextChunk(
Result.getAllocator().CopyString(PrintedNNS));
3395 if (!Proto || !Proto->getMethodQuals())
3401 if (Proto->getMethodQuals().hasOnlyConst()) {
3402 Result.AddInformativeChunk(
" const");
3406 if (Proto->getMethodQuals().hasOnlyVolatile()) {
3407 Result.AddInformativeChunk(
" volatile");
3411 if (Proto->getMethodQuals().hasOnlyRestrict()) {
3412 Result.AddInformativeChunk(
" restrict");
3417 std::string QualsStr;
3418 if (Proto->isConst())
3419 QualsStr +=
" const";
3420 if (Proto->isVolatile())
3421 QualsStr +=
" volatile";
3422 if (Proto->isRestrict())
3423 QualsStr +=
" restrict";
3424 Result.AddInformativeChunk(
Result.getAllocator().CopyString(QualsStr));
3435 switch (Name.getNameKind()) {
3437 const char *OperatorName =
nullptr;
3438 switch (Name.getCXXOverloadedOperator()) {
3440 case OO_Conditional:
3442 OperatorName =
"operator";
3445#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
3447 OperatorName = "operator" Spelling; \
3449#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly)
3450#include "clang/Basic/OperatorKinds.def"
3453 OperatorName =
"operator new";
3456 OperatorName =
"operator delete";
3459 OperatorName =
"operator new[]";
3461 case OO_Array_Delete:
3462 OperatorName =
"operator delete[]";
3465 OperatorName =
"operator()";
3468 OperatorName =
"operator[]";
3471 Result.AddTypedTextChunk(OperatorName);
3479 Result.AddTypedTextChunk(
3492 QualType Ty = Name.getCXXNameType();
3494 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
3496 Record = InjectedTy->getDecl();
3498 Result.AddTypedTextChunk(
3503 Result.AddTypedTextChunk(
3504 Result.getAllocator().CopyString(
Record->getNameAsString()));
3518 bool IncludeBriefComments) {
3520 CCTUInfo, IncludeBriefComments);
3532 return Result.TakeString();
3543 Result.AddPlaceholderChunk(
"...");
3557 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3562 Result.AddPlaceholderChunk(
3563 Result.getAllocator().CopyString((*A)->getName()));
3566 return Result.TakeString();
3578 bool IncludeBriefComments) {
3594 Result.addBriefComment(RC->getBriefText(Ctx));
3604 return Result.TakeString();
3608 PP, Ctx,
Result, IncludeBriefComments, CCContext, Policy);
3612 std::string &BeforeName,
3613 std::string &NameAndSignature) {
3614 bool SeenTypedChunk =
false;
3615 for (
auto &Chunk : CCS) {
3617 assert(SeenTypedChunk &&
"optional parameter before name");
3624 NameAndSignature += Chunk.Text;
3626 BeforeName += Chunk.Text;
3638 std::string BeforeName;
3639 std::string NameAndSignature;
3642 NameAndSignature +=
" override";
3644 Result.AddTextChunk(
Result.getAllocator().CopyString(BeforeName));
3646 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(NameAndSignature));
3647 return Result.TakeString();
3653 const auto *VD = dyn_cast<VarDecl>(ND);
3656 const auto *
RecordDecl = VD->getType()->getAsCXXRecordDecl();
3669 if (IncludeBriefComments) {
3672 Result.addBriefComment(RC->getBriefText(Ctx));
3677 Result.AddTypedTextChunk(
3679 Result.AddTextChunk(
"::");
3680 return Result.TakeString();
3684 Result.AddAnnotation(
Result.getAllocator().CopyString(I->getAnnotation()));
3697 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND)) {
3698 AddFunctionTypeAndResult(
Function);
3699 return Result.TakeString();
3702 if (
const auto *CallOperator =
3704 AddFunctionTypeAndResult(CallOperator);
3705 return Result.TakeString();
3711 dyn_cast<FunctionTemplateDecl>(ND)) {
3722 llvm::SmallBitVector Deduced(FunTmpl->getTemplateParameters()->size());
3727 unsigned LastDeducibleArgument;
3728 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
3729 --LastDeducibleArgument) {
3730 if (!Deduced[LastDeducibleArgument - 1]) {
3734 bool HasDefaultArg =
false;
3735 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3736 LastDeducibleArgument - 1);
3738 HasDefaultArg = TTP->hasDefaultArgument();
3740 dyn_cast<NonTypeTemplateParmDecl>(Param))
3741 HasDefaultArg = NTTP->hasDefaultArgument();
3743 assert(isa<TemplateTemplateParmDecl>(Param));
3745 cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
3768 LastDeducibleArgument);
3777 return Result.TakeString();
3780 if (
const auto *Template = dyn_cast<TemplateDecl>(ND)) {
3783 Result.AddTypedTextChunk(
3784 Result.getAllocator().CopyString(Template->getNameAsString()));
3788 return Result.TakeString();
3791 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3792 Selector Sel = Method->getSelector();
3794 Result.AddTypedTextChunk(
3796 return Result.TakeString();
3802 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(SelName));
3804 Result.AddInformativeChunk(
Result.getAllocator().CopyString(SelName));
3809 Result.AddTypedTextChunk(
"");
3816 P != PEnd && Idx < Sel.
getNumArgs(); (
void)++
P, ++Idx) {
3835 QualType ParamType = (*P)->getType();
3836 std::optional<ArrayRef<QualType>> ObjCSubsts;
3852 Arg += II->getName();
3859 Result.AddTextChunk(
Result.getAllocator().CopyString(Arg));
3861 Result.AddInformativeChunk(
Result.getAllocator().CopyString(Arg));
3863 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3869 Result.AddTextChunk(
", ...");
3871 Result.AddInformativeChunk(
", ...");
3873 Result.AddPlaceholderChunk(
", ...");
3879 return Result.TakeString();
3886 Result.AddTypedTextChunk(
3888 return Result.TakeString();
3899 const auto *M = dyn_cast<ObjCMethodDecl>(ND);
3911 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
3912 if (!M || !M->isPropertyAccessor())
3935 auto FDecl =
Result.getFunction();
3938 if (ArgIndex < FDecl->getNumParams())
3946 unsigned CurrentArg) {
3947 unsigned ChunkIndex = 0;
3948 auto AddChunk = [&](llvm::StringRef Placeholder) {
3951 const char *
Copy =
Result.getAllocator().CopyString(Placeholder);
3952 if (ChunkIndex == CurrentArg)
3960 if (
auto *CRD = llvm::dyn_cast<CXXRecordDecl>(RD)) {
3961 for (
const auto &
Base : CRD->bases())
3962 AddChunk(
Base.getType().getAsString(Policy));
3964 for (
const auto &Field : RD->
fields())
3974 unsigned CurrentArg,
unsigned Start = 0,
bool InOptional =
false) {
3980 bool FirstParameter =
true;
3981 unsigned NumParams =
3984 for (
unsigned P = Start;
P != NumParams; ++
P) {
3989 Result.getCodeCompletionTUInfo());
3990 if (!FirstParameter)
3994 PrototypeLoc, Opt, CurrentArg,
P,
4001 FirstParameter =
false;
4008 std::string Placeholder;
4009 assert(P < Prototype->getNumParams());
4018 Placeholder =
Prototype->getParamType(
P).getAsString(Policy);
4021 if (
P == CurrentArg)
4022 Result.AddCurrentParameterChunk(
4023 Result.getAllocator().CopyString(Placeholder));
4025 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Placeholder));
4030 Result.getCodeCompletionTUInfo());
4031 if (!FirstParameter)
4034 if (CurrentArg < NumParams)
4046 if (
const auto *
Type = dyn_cast<TemplateTypeParmDecl>(Param)) {
4048 }
else if (
const auto *NonType = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4049 Optional = NonType->hasDefaultArgument();
4050 }
else if (
const auto *Template = dyn_cast<TemplateTemplateParmDecl>(Param)) {
4051 Optional = Template->hasDefaultArgument();
4054 llvm::raw_string_ostream OS(
Result);
4055 Param->
print(OS, Policy);
4061 if (
const auto *CTD = dyn_cast<ClassTemplateDecl>(TD))
4062 return CTD->getTemplatedDecl()->getKindName().str();
4063 if (
const auto *VTD = dyn_cast<VarTemplateDecl>(TD))
4064 return VTD->getTemplatedDecl()->getType().getAsString(Policy);
4065 if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(TD))
4066 return FTD->getTemplatedDecl()->getReturnType().getAsString(Policy);
4067 if (isa<TypeAliasTemplateDecl>(TD))
4069 if (isa<TemplateTemplateParmDecl>(TD))
4071 if (isa<ConceptDecl>(TD))
4081 Builder.getCodeCompletionTUInfo());
4083 if (!ResultType.empty())
4084 Builder.AddResultTypeChunk(Builder.getAllocator().CopyString(ResultType));
4085 Builder.AddTextChunk(
4091 for (
unsigned I = 0; I < Params.size(); ++I) {
4093 std::string Placeholder =
4096 Current = &OptionalBuilder;
4099 Current->AddChunk(I == CurrentArg
4102 Current->getAllocator().CopyString(Placeholder));
4105 if (Current == &OptionalBuilder)
4106 Builder.AddOptionalChunk(OptionalBuilder.
TakeString());
4110 if (isa<FunctionTemplateDecl>(TD))
4111 Builder.AddInformativeChunk(
"()");
4112 return Builder.TakeString();
4119 bool Braced)
const {
4143 if (IncludeBriefComments) {
4150 llvm::raw_string_ostream OS(Name);
4152 Result.AddTextChunk(
Result.getAllocator().CopyString(Name));
4155 Result.AddResultTypeChunk(
Result.getAllocator().CopyString(
4170 return Result.TakeString();
4175 bool PreferredTypeIsPointer) {
4179 if (MacroName ==
"nil" || MacroName ==
"NULL" || MacroName ==
"Nil") {
4181 if (PreferredTypeIsPointer)
4185 else if (MacroName ==
"YES" || MacroName ==
"NO" || MacroName ==
"true" ||
4186 MacroName ==
"false")
4189 else if (MacroName ==
"bool")
4202 case Decl::EnumConstant:
4206 case Decl::Function:
4208 case Decl::ObjCCategory:
4210 case Decl::ObjCCategoryImpl:
4212 case Decl::ObjCImplementation:
4215 case Decl::ObjCInterface:
4217 case Decl::ObjCIvar:
4219 case Decl::ObjCMethod:
4220 return cast<ObjCMethodDecl>(
D)->isInstanceMethod()
4223 case Decl::CXXMethod:
4225 case Decl::CXXConstructor:
4227 case Decl::CXXDestructor:
4229 case Decl::CXXConversion:
4231 case Decl::ObjCProperty:
4233 case Decl::ObjCProtocol:
4239 case Decl::TypeAlias:
4241 case Decl::TypeAliasTemplate:
4245 case Decl::Namespace:
4247 case Decl::NamespaceAlias:
4249 case Decl::TemplateTypeParm:
4251 case Decl::NonTypeTemplateParm:
4253 case Decl::TemplateTemplateParm:
4255 case Decl::FunctionTemplate:
4257 case Decl::ClassTemplate:
4259 case Decl::AccessSpec:
4261 case Decl::ClassTemplatePartialSpecialization:
4263 case Decl::UsingDirective:
4265 case Decl::StaticAssert:
4269 case Decl::TranslationUnit:
4273 case Decl::UnresolvedUsingValue:
4274 case Decl::UnresolvedUsingTypename:
4277 case Decl::UsingEnum:
4280 case Decl::ObjCPropertyImpl:
4281 switch (cast<ObjCPropertyImplDecl>(
D)->getPropertyImplementation()) {
4288 llvm_unreachable(
"Unexpected Kind!");
4293 case Decl::ObjCTypeParam:
4299 case Decl::LinkageSpec:
4303 if (
const auto *TD = dyn_cast<TagDecl>(
D)) {
4304 switch (TD->getTagKind()) {
4322 bool LoadExternal,
bool IncludeUndefined,
4323 bool TargetTypeIsPointer =
false) {
4326 Results.EnterNewScope();
4332 if (IncludeUndefined || MD) {
4340 TargetTypeIsPointer)));
4344 Results.ExitScope();
4348 ResultBuilder &Results) {
4351 Results.EnterNewScope();
4355 if (LangOpts.C99 || LangOpts.CPlusPlus11)
4357 Results.ExitScope();
4364 unsigned NumResults) {
4427 llvm_unreachable(
"Invalid ParserCompletionContext!");
4439 ResultBuilder &Results) {
4442 while (isa<BlockDecl>(CurContext))
4445 CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(CurContext);
4452 if (!
P->getDeclName())
4458 Results.getCodeCompletionTUInfo());
4465 S.
Context, CurContext, Overridden->getDeclContext());
4468 llvm::raw_string_ostream OS(Str);
4469 NNS->
print(OS, Policy);
4470 Builder.AddTextChunk(Results.getAllocator().CopyString(Str));
4472 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
4475 Builder.AddTypedTextChunk(
4476 Results.getAllocator().CopyString(Overridden->getNameAsString()));
4478 bool FirstParam =
true;
4485 Builder.AddPlaceholderChunk(
4486 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
4492 Results.Ignore(Overridden);
4499 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4500 CodeCompleter->getCodeCompletionTUInfo(),
4502 Results.EnterNewScope();
4511 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
4512 Builder.AddTypedTextChunk(
4513 Builder.getAllocator().CopyString(Modules[I]->Name));
4514 Results.AddResult(
Result(
4519 }
else if (getLangOpts().Modules) {
4527 Builder.AddTypedTextChunk(
4528 Builder.getAllocator().CopyString(Submodule->Name));
4529 Results.AddResult(
Result(
4536 Results.ExitScope();
4538 Results.getCompletionContext(), Results.data(),
4544 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4545 CodeCompleter->getCodeCompletionTUInfo(),
4547 Results.EnterNewScope();
4552 switch (CompletionContext) {
4555 case PCC_ObjCInterface:
4556 case PCC_ObjCImplementation:
4557 case PCC_ObjCInstanceVariableList:
4559 case PCC_MemberTemplate:
4561 case PCC_LocalDeclarationSpecifiers:
4562 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
4566 case PCC_TopLevelOrExpression:
4567 case PCC_ParenthesizedExpression:
4568 case PCC_Expression:
4572 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4574 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4580 case PCC_RecoveryInFunction:
4588 if (!ThisType.isNull())
4589 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
4592 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4594 CodeCompleter->includeGlobals(),
4595 CodeCompleter->loadExternal());
4598 Results.ExitScope();
4600 switch (CompletionContext) {
4601 case PCC_ParenthesizedExpression:
4602 case PCC_Expression:
4604 case PCC_TopLevelOrExpression:
4605 case PCC_RecoveryInFunction:
4606 if (S->getFnParent())
4612 case PCC_ObjCInterface:
4613 case PCC_ObjCImplementation:
4614 case PCC_ObjCInstanceVariableList:
4616 case PCC_MemberTemplate:
4620 case PCC_LocalDeclarationSpecifiers:
4624 if (CodeCompleter->includeMacros())
4628 Results.getCompletionContext(), Results.data(),
4635 bool AtArgumentExpression,
bool IsSuper,
4636 ResultBuilder &Results);
4639 bool AllowNonIdentifiers,
4640 bool AllowNestedNameSpecifiers) {
4642 ResultBuilder Results(
4643 SemaRef, CodeCompleter->getAllocator(),
4644 CodeCompleter->getCodeCompletionTUInfo(),
4645 AllowNestedNameSpecifiers
4650 Results.EnterNewScope();
4653 Results.AddResult(
Result(
"const"));
4654 Results.AddResult(
Result(
"volatile"));
4655 if (getLangOpts().
C99)
4656 Results.AddResult(
Result(
"restrict"));
4662 Results.AddResult(
"final");
4664 if (AllowNonIdentifiers) {
4665 Results.AddResult(
Result(
"operator"));
4669 if (AllowNestedNameSpecifiers) {
4670 Results.allowNestedNameSpecifiers();
4671 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
4672 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4674 Consumer, CodeCompleter->includeGlobals(),
4675 CodeCompleter->loadExternal());
4676 Results.setFilter(
nullptr);
4679 Results.ExitScope();
4685 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
4704 Results.getCompletionContext(), Results.data(),
4709 if (
Scope ==
"clang")
4717 if (
Scope ==
"_Clang")
4719 if (
Scope ==
"__gnu__")
4727 if (Completion == AttributeCompletion::None)
4729 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4730 CodeCompleter->getCodeCompletionTUInfo(),
4743 llvm::StringRef InScopeName;
4744 bool InScopeUnderscore =
false;
4746 InScopeName = InScope->
getName();
4748 InScopeName = NoUnderscore;
4749 InScopeUnderscore =
true;
4756 llvm::DenseSet<llvm::StringRef> FoundScopes;
4758 if (A.IsTargetSpecific &&
4759 !A.existsInTarget(getASTContext().getTargetInfo()))
4761 if (!A.acceptsLangOpts(getLangOpts()))
4763 for (
const auto &S : A.Spellings) {
4764 if (S.Syntax != Syntax)
4766 llvm::StringRef Name = S.NormalizedFullName;
4767 llvm::StringRef
Scope;
4770 std::tie(
Scope, Name) = Name.split(
"::");
4772 std::swap(Name,
Scope);
4776 if (Completion == AttributeCompletion::Scope) {
4778 if (!
Scope.empty() && FoundScopes.insert(
Scope).second) {
4789 if (!InScopeName.empty()) {
4790 if (
Scope != InScopeName)
4795 auto Add = [&](llvm::StringRef
Scope, llvm::StringRef Name,
4798 Results.getCodeCompletionTUInfo());
4800 if (!
Scope.empty()) {
4809 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
Text));
4811 if (!A.ArgNames.empty()) {
4814 for (
const char *Arg : A.ArgNames) {
4818 Builder.AddPlaceholderChunk(Arg);
4823 Results.AddResult(Builder.TakeString());
4830 if (!InScopeUnderscore)
4831 Add(
Scope, Name,
false);
4836 if (!(InScope && !InScopeUnderscore) && SyntaxSupportsGuards) {
4838 if (
Scope.empty()) {
4839 Add(
Scope, Name,
true);
4844 Add(GuardedScope, Name,
true);
4854 for (
const auto &Entry : ParsedAttrInfoRegistry::entries())
4855 AddCompletions(*Entry.instantiate());
4858 Results.getCompletionContext(), Results.data(),
4864 bool IsParenthesized =
false)
4865 : PreferredType(PreferredType), IntegralConstantExpression(
false),
4866 ObjCCollection(
false), IsParenthesized(IsParenthesized) {}
4877struct CoveredEnumerators {
4885 const CoveredEnumerators &Enumerators) {
4887 if (Context.
getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) {
4894 Results.EnterNewScope();
4895 for (
auto *
E :
Enum->enumerators()) {
4896 if (Enumerators.Seen.count(
E))
4900 Results.AddResult(R, CurContext,
nullptr,
false);
4902 Results.ExitScope();
4908 assert(!
T.isNull());
4931 if (!Results.includeCodePatterns())
4934 Results.getCodeCompletionTUInfo());
4939 if (!Parameters.empty()) {
4948 constexpr llvm::StringLiteral NamePlaceholder =
"!#!NAME_GOES_HERE!#!";
4949 std::string
Type = std::string(NamePlaceholder);
4951 llvm::StringRef Prefix, Suffix;
4952 std::tie(Prefix, Suffix) = llvm::StringRef(
Type).split(NamePlaceholder);
4953 Prefix = Prefix.rtrim();
4954 Suffix = Suffix.ltrim();
4977 ResultBuilder Results(
4978 SemaRef, CodeCompleter->getAllocator(),
4979 CodeCompleter->getCodeCompletionTUInfo(),
4981 Data.IsParenthesized
4984 Data.PreferredType));
4986 Data.IsParenthesized ? PCC_ParenthesizedExpression : PCC_Expression;
4987 if (
Data.ObjCCollection)
4988 Results.setFilter(&ResultBuilder::IsObjCCollection);
4989 else if (
Data.IntegralConstantExpression)
4990 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
4992 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4994 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4996 if (!
Data.PreferredType.isNull())
4997 Results.setPreferredType(
Data.PreferredType.getNonReferenceType());
5000 for (
unsigned I = 0, N =
Data.IgnoreDecls.size(); I != N; ++I)
5001 Results.Ignore(
Data.IgnoreDecls[I]);
5003 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
5005 CodeCompleter->includeGlobals(),
5006 CodeCompleter->loadExternal());
5008 Results.EnterNewScope();
5010 Results.ExitScope();
5012 bool PreferredTypeIsPointer =
false;
5013 if (!
Data.PreferredType.isNull()) {
5014 PreferredTypeIsPointer =
Data.PreferredType->isAnyPointerType() ||
5015 Data.PreferredType->isMemberPointerType() ||
5016 Data.PreferredType->isBlockPointerType();
5017 if (
Data.PreferredType->isEnumeralType()) {
5019 if (
auto *Def =
Enum->getDefinition())
5024 CoveredEnumerators());
5028 if (S->getFnParent() && !
Data.ObjCCollection &&
5029 !
Data.IntegralConstantExpression)
5032 if (CodeCompleter->includeMacros())
5034 PreferredTypeIsPointer);
5044 Results.getCompletionContext(), Results.data(),
5050 bool IsParenthesized) {
5051 return CodeCompleteExpression(
5058 CodeCompleteExpression(S, PreferredType);
5059 else if (getLangOpts().
ObjC)
5060 CodeCompleteObjCInstanceMessage(S,
E.get(), {},
false);
5077 if (Protocol->hasDefinition())
5078 return Protocol->getDefinition();
5092 Builder.AddResultTypeChunk(
5094 Policy, Builder.getAllocator()));
5100 Builder.AddPlaceholderChunk(
"...");
5102 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
5107 std::string PlaceholderStr =
5110 if (I == N - 1 && BlockProtoLoc &&
5112 PlaceholderStr +=
", ...";
5115 Builder.AddPlaceholderChunk(
5116 Builder.getAllocator().CopyString(PlaceholderStr));
5126 bool AllowNullaryMethods,
DeclContext *CurContext,
5128 bool IsBaseExprStatement =
false,
5129 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
5137 if (!AddedProperties.insert(
P->getIdentifier()).second)
5142 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
5143 !IsBaseExprStatement) {
5145 if (!InOriginalClass)
5147 Results.MaybeAddResult(R, CurContext);
5159 if (!InOriginalClass)
5161 Results.MaybeAddResult(R, CurContext);
5168 Results.getCodeCompletionTUInfo());
5171 BlockLoc, BlockProtoLoc);
5172 Result R =
Result(Builder.TakeString(),
P, Results.getBasePriority(
P));
5173 if (!InOriginalClass)
5175 Results.MaybeAddResult(R, CurContext);
5179 if (!
P->isReadOnly()) {
5181 Results.getCodeCompletionTUInfo());
5185 Builder.AddTypedTextChunk(
5186 Results.getAllocator().CopyString(
P->getName()));
5191 BlockProtoLoc,
true);
5193 Builder.AddPlaceholderChunk(
5194 Builder.getAllocator().CopyString(PlaceholderStr));
5202 Result(Builder.TakeString(),
P,
5203 Results.getBasePriority(
P) +
5207 if (!InOriginalClass)
5209 Results.MaybeAddResult(R, CurContext);
5213 if (IsClassProperty) {
5214 for (
const auto *
P : Container->class_properties())
5217 for (
const auto *
P : Container->instance_properties())
5222 if (AllowNullaryMethods) {
5223 ASTContext &Context = Container->getASTContext();
5227 const IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
5230 if (!AddedProperties.insert(Name).second)
5233 Results.getCodeCompletionTUInfo());
5235 Builder.AddTypedTextChunk(
5236 Results.getAllocator().CopyString(Name->getName()));
5239 if (!InOriginalClass)
5241 Results.MaybeAddResult(R, CurContext);
5244 if (IsClassProperty) {
5245 for (
const auto *M : Container->methods()) {
5249 if (!M->getSelector().isUnarySelector() ||
5250 M->getReturnType()->isVoidType() || M->isInstanceMethod())
5255 for (
auto *M : Container->methods()) {
5256 if (M->getSelector().isUnarySelector())
5264 for (
auto *
P : Protocol->protocols())
5266 CurContext, AddedProperties, Results,
5267 IsBaseExprStatement, IsClassProperty,
5270 dyn_cast<ObjCInterfaceDecl>(Container)) {
5271 if (AllowCategories) {
5273 for (
auto *Cat : IFace->known_categories())
5275 CurContext, AddedProperties, Results,
5276 IsBaseExprStatement, IsClassProperty,
5281 for (
auto *I : IFace->all_referenced_protocols())
5283 CurContext, AddedProperties, Results,
5284 IsBaseExprStatement, IsClassProperty,
5288 if (IFace->getSuperClass())
5290 AllowNullaryMethods, CurContext, AddedProperties,
5291 Results, IsBaseExprStatement, IsClassProperty,
5294 dyn_cast<ObjCCategoryDecl>(Container)) {
5298 CurContext, AddedProperties, Results,
5299 IsBaseExprStatement, IsClassProperty,
5308 std::optional<FixItHint> AccessOpFixIt) {
5311 Results.setObjectTypeQualifiers(BaseType.
getQualifiers(), BaseKind);
5314 Results.allowNestedNameSpecifiers();
5315 std::vector<FixItHint> FixIts;
5317 FixIts.emplace_back(*AccessOpFixIt);
5318 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
5326 if (!Results.empty()) {
5332 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->getParent())
5351 if (
const auto *CTSD =
5352 llvm::dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
5356 RD = CTSD->getSpecializedTemplate()->getTemplatedDecl();
5362 if (
const auto *TD = dyn_cast_or_null<ClassTemplateDecl>(
5363 TST->getTemplateName().getAsTemplateDecl())) {
5364 return TD->getTemplatedDecl();
5408 std::optional<SmallVector<QualType, 1>> ArgTypes;
5410 enum AccessOperator {
5427 std::string AsString;
5429 llvm::raw_string_ostream OS(AsString);
5430 QualType ExactType = deduceType(*ResultType);
5436 B.AddResultTypeChunk(
Alloc.CopyString(AsString));
5439 B.AddTypedTextChunk(
Alloc.CopyString(Name->getName()));
5451 B.AddPlaceholderChunk(
Alloc.CopyString(
5456 return B.TakeString();
5464 auto *TemplatedEntity = getTemplatedEntity(BaseType.
getDecl(), S);
5465 for (
const Expr *
E : constraintsForTemplatedEntity(TemplatedEntity))
5466 believe(
E, &BaseType);
5469 std::vector<Member> members() {
5470 std::vector<Member> Results;
5471 for (
const auto &
E : this->Results)
5472 Results.push_back(
E.second);
5473 llvm::sort(Results, [](
const Member &L,
const Member &R) {
5474 return L.Name->getName() < R.Name->getName();
5484 if (
auto *CSE = dyn_cast<ConceptSpecializationExpr>(
E)) {
5498 for (
const auto &Arg : CSE->getTemplateArguments()) {
5499 if (Index >= Params->
size())
5501 if (isApprox(Arg,
T)) {
5502 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Params->
getParam(Index));
5506 auto *TT = cast<TemplateTypeParmType>(TTPD->getTypeForDecl());
5514 }
else if (
auto *BO = dyn_cast<BinaryOperator>(
E)) {
5517 if (BO->getOpcode() == BO_LAnd || BO->getOpcode() == BO_LOr) {
5518 believe(BO->getLHS(),
T);
5519 believe(BO->getRHS(),
T);
5521 }
else if (
auto *RE = dyn_cast<RequiresExpr>(
E)) {
5524 if (!Req->isDependent())
5528 if (
auto *TR = dyn_cast<concepts::TypeRequirement>(Req)) {
5530 QualType AssertedType = TR->getType()->getType();
5531 ValidVisitor(
this,
T).TraverseType(AssertedType);
5532 }
else if (
auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
5533 ValidVisitor Visitor(
this,
T);
5537 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
5539 ER->getReturnTypeRequirement().getTypeConstraint();
5540 Visitor.OuterExpr = ER->getExpr();
5542 Visitor.TraverseStmt(ER->getExpr());
5543 }
else if (
auto *NR = dyn_cast<concepts::NestedRequirement>(Req)) {
5544 believe(NR->getConstraintExpr(),
T);
5561 Expr *OuterExpr =
nullptr;
5565 : Outer(Outer),
T(
T) {
5572 const Type *
Base =
E->getBaseType().getTypePtr();
5573 bool IsArrow =
E->isArrow();
5574 if (
Base->isPointerType() && IsArrow) {
5576 Base =
Base->getPointeeType().getTypePtr();
5578 if (isApprox(
Base,
T))
5579 addValue(
E,
E->getMember(), IsArrow ? Member::Arrow : Member::Dot);
5585 if (
E->getQualifier() && isApprox(
E->getQualifier()->getAsType(),
T))
5586 addValue(
E,
E->getDeclName(), Member::Colons);
5593 if (Q && isApprox(Q->getAsType(),
T))
5604 if (Q && isApprox(Q->getAsType(),
T))
5615 bool VisitCallExpr(
CallExpr *CE)
override {
5622 void addResult(
Member &&M) {
5623 auto R = Outer->Results.try_emplace(M.Name);
5624 Member &O = R.first->second;
5628 std::make_tuple(M.ArgTypes.has_value(), M.ResultType !=
nullptr,
5629 M.Operator) > std::make_tuple(O.ArgTypes.has_value(),
5630 O.ResultType !=
nullptr,
5640 M.Operator = Member::Colons;
5641 addResult(std::move(M));
5645 Member::AccessOperator Operator) {
5646 if (!Name.isIdentifier())
5649 Result.Name = Name.getAsIdentifierInfo();
5650 Result.Operator = Operator;
5653 if (Caller !=
nullptr && Callee ==
E) {
5654 Result.ArgTypes.emplace();
5655 for (
const auto *Arg : Caller->
arguments())
5656 Result.ArgTypes->push_back(Arg->getType());
5657 if (Caller == OuterExpr) {
5658 Result.ResultType = OuterType;
5662 Result.ResultType = OuterType;
5664 addResult(std::move(Result));
5673 static bool isApprox(
const Type *T1,
const Type *T2) {
5686 Scope *Inner =
nullptr;
5688 if (S->isTemplateParamScope() && S->isDeclScope(
D))
5689 return Inner ? Inner->getEntity() :
nullptr;
5705 TD->getAssociatedConstraints(Result);
5707 if (
const auto *CTPSD =
5708 dyn_cast<ClassTemplatePartialSpecializationDecl>(DC))
5709 CTPSD->getAssociatedConstraints(Result);
5710 if (
const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl>(DC))
5711 VTPSD->getAssociatedConstraints(Result);
5722 if (
const auto *Args =
T.getTemplateArgsAsWritten())
5723 if (Args->getNumTemplateArgs() == 1) {
5724 const auto &Arg = Args->arguments().front().getArgument();
5731 llvm::DenseMap<const IdentifierInfo *, Member> Results;
5744 if (!
Unresolved->isSpecificBuiltinType(BuiltinType::Dependent)) {
5746 if (!
Auto || !
Auto->isUndeducedAutoType())
5750 if (
const CallExpr *CE = llvm::dyn_cast<CallExpr>(
E)) {
5753 Callee->isSpecificPlaceholderType(BuiltinType::BoundMember))
5759 Callee = FnTypePtr->getPointeeType();
5761 Callee = BPT->getPointeeType();
5764 return FnType->getReturnType().getNonReferenceType();
5767 if (
const auto *OE = llvm::dyn_cast<OverloadExpr>(CE->
getCallee())) {
5771 const Type *Common =
nullptr;
5772 for (
const auto *
D : OE->decls()) {
5774 if (
const auto *FD = llvm::dyn_cast<FunctionDecl>(
D))
5775 ReturnType = FD->getReturnType();
5776 else if (
const auto *FTD = llvm::dyn_cast<FunctionTemplateDecl>(
D))
5777 ReturnType = FTD->getTemplatedDecl()->getReturnType();
5780 const Type *Candidate =
5782 if (Common && Common != Candidate)
5786 if (Common !=
nullptr)
5791 if (
const auto *CDSME = llvm::dyn_cast<CXXDependentScopeMemberExpr>(
E)) {
5793 ? CDSME->getBaseType()
5794 : getApproximateType(CDSME->getBase());
5795 if (CDSME->isArrow() && !
Base.isNull())
5801 if (RD && RD->isCompleteDefinition()) {
5803 for (
const auto *
Member : RD->lookupDependentName(
5805 return llvm::isa<ValueDecl>(Member);
5807 return llvm::cast<ValueDecl>(
Member)->getType().getNonReferenceType();
5812 if (
const auto *DRE = llvm::dyn_cast<DeclRefExpr>(
E)) {
5813 if (
const auto *VD = llvm::dyn_cast<VarDecl>(DRE->getDecl())) {
5815 return getApproximateType(VD->getInit());
5818 if (
const auto *UO = llvm::dyn_cast<UnaryOperator>(
E)) {
5819 if (UO->getOpcode() == UnaryOperatorKind::UO_Deref) {
5822 if (
auto Pointee = getApproximateType(UO->getSubExpr())->getPointeeType();
5837 if (
auto *PLE = llvm::dyn_cast_or_null<ParenListExpr>(
Base)) {
5838 if (PLE->getNumExprs() == 0)
5840 Base = PLE->getExpr(PLE->getNumExprs() - 1);
5849 bool IsBaseExprStatement,
QualType PreferredType) {
5851 OtherOpBase = unwrapParenList(OtherOpBase);
5852 if (!
Base || !CodeCompleter)
5859 QualType ConvertedBaseType = getApproximateType(ConvertedBase.
get());
5881 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5882 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
5883 &ResultBuilder::IsMember);
5885 auto DoCompletion = [&](
Expr *
Base,
bool IsArrow,
5886 std::optional<FixItHint> AccessOpFixIt) ->
bool {
5915 RD, std::move(AccessOpFixIt));
5916 }
else if (
const auto *TTPT =
5917 dyn_cast<TemplateTypeParmType>(BaseType.
getTypePtr())) {
5919 IsArrow ? ConceptInfo::Member::Arrow : ConceptInfo::Member::Dot;
5920 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
5921 if (R.Operator != Operator)
5924 R.render(SemaRef, CodeCompleter->getAllocator(),
5925 CodeCompleter->getCodeCompletionTUInfo()));
5927 Result.FixIts.push_back(*AccessOpFixIt);
5928 Results.AddResult(std::move(
Result));
5934 if (AccessOpFixIt) {
5942 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
5945 AddedProperties, Results, IsBaseExprStatement);
5951 SemaRef.
CurContext, AddedProperties, Results,
5952 IsBaseExprStatement,
false,
5959 if (AccessOpFixIt) {
5965 Class = ObjCPtr->getInterfaceDecl();
5971 CodeCompletionDeclConsumer Consumer(Results,
Class, BaseType);
5972 Results.setFilter(&ResultBuilder::IsObjCIvar);
5974 CodeCompleter->includeGlobals(),
5976 CodeCompleter->loadExternal());
5984 Results.EnterNewScope();
5986 bool CompletionSucceded = DoCompletion(
Base, IsArrow, std::nullopt);
5987 if (CodeCompleter->includeFixIts()) {
5990 CompletionSucceded |= DoCompletion(
5991 OtherOpBase, !IsArrow,
5995 Results.ExitScope();
5997 if (!CompletionSucceded)
6002 Results.getCompletionContext(), Results.data(),
6008 bool IsBaseExprStatement) {
6016 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6017 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
6018 &ResultBuilder::IsMember);
6019 Results.EnterNewScope();
6023 AddedProperties, Results, IsBaseExprStatement,
6025 Results.ExitScope();
6027 Results.getCompletionContext(), Results.data(),
6035 ResultBuilder::LookupFilter Filter =
nullptr;
6040 Filter = &ResultBuilder::IsEnum;
6045 Filter = &ResultBuilder::IsUnion;
6052 Filter = &ResultBuilder::IsClassOrStruct;
6057 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
6060 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6061 CodeCompleter->getCodeCompletionTUInfo(), ContextKind);
6062 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6065 Results.setFilter(Filter);
6067 CodeCompleter->includeGlobals(),
6068 CodeCompleter->loadExternal());
6070 if (CodeCompleter->includeGlobals()) {
6072 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
6074 CodeCompleter->includeGlobals(),
6075 CodeCompleter->loadExternal());
6079 Results.getCompletionContext(), Results.data(),
6086 Results.AddResult(
"const");
6088 Results.AddResult(
"volatile");
6090 Results.AddResult(
"restrict");
6092 Results.AddResult(
"_Atomic");
6094 Results.AddResult(
"__unaligned");
6098 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6099 CodeCompleter->getCodeCompletionTUInfo(),
6101 Results.EnterNewScope();
6103 Results.ExitScope();
6105 Results.getCompletionContext(), Results.data(),
6111 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6112 CodeCompleter->getCodeCompletionTUInfo(),
6114 Results.EnterNewScope();
6117 Results.AddResult(
"noexcept");
6119 !
D.isStaticMember()) {
6121 Results.AddResult(
"final");
6123 Results.AddResult(
"override");
6126 Results.ExitScope();
6128 Results.getCompletionContext(), Results.data(),
6133 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
6146 if (!
type->isEnumeralType()) {
6148 Data.IntegralConstantExpression =
true;
6149 CodeCompleteExpression(S,
Data);
6163 CoveredEnumerators Enumerators;
6165 SC = SC->getNextSwitchCase()) {
6166 CaseStmt *Case = dyn_cast<CaseStmt>(SC);
6171 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
6172 if (
auto *Enumerator =
6173 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
6180 Enumerators.Seen.insert(Enumerator);
6193 Enumerators.SuggestedQualifier = DRE->getQualifier();
6198 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6199 CodeCompleter->getCodeCompletionTUInfo(),
6204 if (CodeCompleter->includeMacros()) {
6208 Results.getCompletionContext(), Results.data(),
6213 if (Args.size() && !Args.data())
6216 for (
unsigned I = 0; I != Args.size(); ++I)
6237 if (Candidate.Function) {
6238 if (Candidate.Function->isDeleted())
6241 Candidate.Function) &&
6242 Candidate.Function->getNumParams() <= ArgSize &&
6251 if (Candidate.Viable)
6265 for (
auto &Candidate : Candidates) {
6266 QualType CandidateParamType = Candidate.getParamType(N);
6267 if (CandidateParamType.
isNull())
6269 if (ParamType.
isNull()) {
6270 ParamType = CandidateParamType;
6287 if (Candidates.empty())
6291 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc,
6302 if (
const auto *
T = Fn->getType().getTypePtr()->getAs<
TypedefType>()) {
6303 Target =
T->getDecl()->getTypeSourceInfo()->getTypeLoc();
6305 }
else if (
const auto *DR = dyn_cast<DeclRefExpr>(Fn)) {
6306 const auto *
D = DR->getDecl();
6307 if (
const auto *
const VD = dyn_cast<VarDecl>(
D)) {
6308 Target = VD->getTypeSourceInfo()->getTypeLoc();
6310 }
else if (
const auto *ME = dyn_cast<MemberExpr>(Fn)) {
6311 const auto *MD = ME->getMemberDecl();
6312 if (
const auto *FD = dyn_cast<FieldDecl>(MD)) {
6313 Target = FD->getTypeSourceInfo()->getTypeLoc();
6327 Target = A.getModifiedLoc();
6347 Fn = unwrapParenList(Fn);
6348 if (!CodeCompleter || !Fn)
6358 auto ArgsWithoutDependentTypes =
6363 Expr *NakedFn = Fn->IgnoreParenCasts();
6368 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
6372 }
else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
6374 if (UME->hasExplicitTemplateArgs()) {
6375 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
6376 TemplateArgs = &TemplateArgsBuffer;
6381 1, UME->isImplicitAccess() ?
nullptr : UME->getBase());
6382 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6383 ArgsWithoutDependentTypes.end());
6385 Decls.
append(UME->decls_begin(), UME->decls_end());
6386 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
6390 FirstArgumentIsBase);
6393 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
6394 FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl());
6395 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
6396 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
6404 ArgsWithoutDependentTypes, CandidateSet,
6414 getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
6419 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6420 ArgsWithoutDependentTypes.end());
6438 ArgsWithoutDependentTypes.size(),
6474static std::optional<unsigned>
6477 static constexpr unsigned Invalid = std::numeric_limits<unsigned>::max();
6483 unsigned ArgsAfterDesignator = 0;
6484 for (
const Expr *Arg : Args) {
6485 if (
const auto *DIE = dyn_cast<DesignatedInitExpr>(Arg)) {
6486 if (DIE->size() == 1 && DIE->getDesignator(0)->isFieldDesignator()) {
6487 DesignatedFieldName = DIE->getDesignator(0)->getFieldName();
6488 ArgsAfterDesignator = 0;
6492 }
else if (isa<DesignatedInitUpdateExpr>(Arg)) {
6495 ++ArgsAfterDesignator;
6498 if (!DesignatedFieldName)
6499 return std::nullopt;
6503 unsigned DesignatedIndex = 0;
6504 const FieldDecl *DesignatedField =
nullptr;
6505 for (
const auto *Field :
Aggregate.getAggregate()->fields()) {
6506 if (Field->getIdentifier() == DesignatedFieldName) {
6507 DesignatedField = Field;
6512 if (!DesignatedField)
6516 unsigned AggregateSize =
Aggregate.getNumParams();
6517 while (DesignatedIndex < AggregateSize &&
6518 Aggregate.getParamDecl(DesignatedIndex) != DesignatedField)
6522 return DesignatedIndex + ArgsAfterDesignator + 1;
6545 if (Braced && !RD->
isUnion() &&
6550 if (
auto NextIndex =
6553 if (*NextIndex >= AggregateSize)
6555 Results.push_back(AggregateSig);
6561 if (Args.size() < AggregateSize)
6562 Results.push_back(AggregateSig);
6571 if (
auto *FD = dyn_cast<FunctionDecl>(
C)) {
6574 if (Braced && getLangOpts().
CPlusPlus &&
6582 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
6583 if (Braced && getLangOpts().
CPlusPlus &&
6589 nullptr, Args, CandidateSet,
6610 dyn_cast<CXXConstructorDecl>(ConstructorDecl);
6615 Constructor->getParent(), SS, TemplateTypeTy, II))
6616 return ProduceConstructorSignatureHelp(MemberDecl->getType(),
6617 MemberDecl->getLocation(), ArgExprs,
6618 OpenParLoc, Braced);
6626 if (Index < Params.
size())
6629 Param = Params.
asArray().back();
6635 return llvm::isa<TemplateTypeParmDecl>(Param);
6637 return llvm::isa<NonTypeTemplateParmDecl>(Param);
6639 return llvm::isa<TemplateTemplateParmDecl>(Param);
6641 llvm_unreachable(
"Unhandled switch case");
6647 if (!CodeCompleter || !ParsedTemplate)
6653 bool Matches =
true;
6654 for (
unsigned I = 0; I < Args.size(); ++I) {
6661 Results.emplace_back(TD);
6669 if (
const auto *TD = llvm::dyn_cast<TemplateDecl>(ND))
6682 if (
D.isArrayDesignator() ||
D.isArrayRangeDesignator()) {
6686 assert(
D.isFieldDesignator());
6688 if (RD && RD->isCompleteDefinition()) {
6689 for (
const auto *
Member : RD->lookup(
D.getFieldDecl()))
6691 NextType = FD->getType();
6696 BaseType = NextType;
6707 if (!RD || RD->fields().empty())
6712 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6713 CodeCompleter->getCodeCompletionTUInfo(), CCC);
6715 Results.EnterNewScope();
6716 for (
const Decl *
D : RD->decls()) {
6718 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(
D))
6719 FD = IFD->getAnonField();
6720 else if (
auto *DFD = dyn_cast<FieldDecl>(
D))
6730 Results.ExitScope();
6732 Results.getCompletionContext(), Results.data(),
6737 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(
D);
6739 CodeCompleteOrdinaryName(S, PCC_Expression);
6746 Data.IgnoreDecls.push_back(VD);
6748 CodeCompleteExpression(S,
Data);
6752 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6753 CodeCompleter->getCodeCompletionTUInfo(),
6755 Results.setFilter(&ResultBuilder::IsOrdinaryName);
6756 Results.EnterNewScope();
6758 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6760 CodeCompleter->includeGlobals(),
6761 CodeCompleter->loadExternal());
6767 Results.getCodeCompletionTUInfo());
6769 auto AddElseBodyPattern = [&] {
6774 Builder.AddPlaceholderChunk(
"statements");
6780 Builder.AddPlaceholderChunk(
"statement");
6784 Builder.AddTypedTextChunk(
"else");
6785 if (Results.includeCodePatterns())
6786 AddElseBodyPattern();
6787 Results.AddResult(Builder.TakeString());
6790 Builder.AddTypedTextChunk(
"else if");
6794 Builder.AddPlaceholderChunk(
"condition");
6796 Builder.AddPlaceholderChunk(
"expression");
6798 if (Results.includeCodePatterns()) {
6799 AddElseBodyPattern();
6801 Results.AddResult(Builder.TakeString());
6803 Results.ExitScope();
6805 if (S->getFnParent())
6808 if (CodeCompleter->includeMacros())
6812 Results.getCompletionContext(), Results.data(),
6817 bool EnteringContext,
6818 bool IsUsingDeclaration,
6821 if (SS.
isEmpty() || !CodeCompleter)
6836 ResultBuilder DummyResults(SemaRef, CodeCompleter->getAllocator(),
6837 CodeCompleter->getCodeCompletionTUInfo(), CC);
6838 if (!PreferredType.
isNull())
6839 DummyResults.setPreferredType(PreferredType);
6840 if (S->getEntity()) {
6841 CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
6848 DummyResults.getCompletionContext(),
nullptr, 0);
6863 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6864 CodeCompleter->getCodeCompletionTUInfo(), CC);
6865 if (!PreferredType.
isNull())
6866 Results.setPreferredType(PreferredType);
6867 Results.EnterNewScope();
6872 if (!Results.empty() && NNS && NNS->
isDependent())
6873 Results.AddResult(
"template");
6878 if (
const auto *TTPT =
6879 dyn_cast_or_null<TemplateTypeParmType>(NNS->
getAsType())) {
6880 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
6881 if (R.Operator != ConceptInfo::Member::Colons)
6884 R.render(SemaRef, CodeCompleter->getAllocator(),
6885 CodeCompleter->getCodeCompletionTUInfo())));
6895 if (Ctx && !EnteringContext)
6897 Results.ExitScope();
6900 (CodeCompleter->includeNamespaceLevelDecls() || !Ctx->
isFileContext())) {
6901 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
6905 CodeCompleter->loadExternal());
6909 Results.getCompletionContext(), Results.data(),
6920 Context.setIsUsingDeclaration(
true);
6922 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6923 CodeCompleter->getCodeCompletionTUInfo(), Context,
6924 &ResultBuilder::IsNestedNameSpecifier);
6925 Results.EnterNewScope();
6928 if (!S->isClassScope())
6933 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6935 CodeCompleter->includeGlobals(),
6936 CodeCompleter->loadExternal());
6937 Results.ExitScope();
6940 Results.getCompletionContext(), Results.data(),
6950 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6951 CodeCompleter->getCodeCompletionTUInfo(),
6953 &ResultBuilder::IsNamespaceOrAlias);
6954 Results.EnterNewScope();
6955 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6957 CodeCompleter->includeGlobals(),
6958 CodeCompleter->loadExternal());
6959 Results.ExitScope();
6961 Results.getCompletionContext(), Results.data(),
6970 if (!S->getParent())
6971 Ctx = getASTContext().getTranslationUnitDecl();
6973 bool SuppressedGlobalResults =
6974 Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
6976 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6977 CodeCompleter->getCodeCompletionTUInfo(),
6978 SuppressedGlobalResults
6981 &ResultBuilder::IsNamespace);
6983 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
6988 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
6993 OrigToLatest[NS->getFirstDecl()] = *NS;
6997 Results.EnterNewScope();
6998 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
6999 NS = OrigToLatest.begin(),
7000 NSEnd = OrigToLatest.end();
7006 Results.ExitScope();
7010 Results.getCompletionContext(), Results.data(),
7019 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7020 CodeCompleter->getCodeCompletionTUInfo(),
7022 &ResultBuilder::IsNamespaceOrAlias);
7023 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7025 CodeCompleter->includeGlobals(),
7026 CodeCompleter->loadExternal());
7028 Results.getCompletionContext(), Results.data(),
7037 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7038 CodeCompleter->getCodeCompletionTUInfo(),
7040 &ResultBuilder::IsType);
7041 Results.EnterNewScope();
7045#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
7046 if (OO_##Name != OO_Conditional) \
7047 Results.AddResult(Result(Spelling));
7048#include "clang/Basic/OperatorKinds.def"
7051 Results.allowNestedNameSpecifiers();
7052 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7054 CodeCompleter->includeGlobals(),
7055 CodeCompleter->loadExternal());
7059 Results.ExitScope();
7062 Results.getCompletionContext(), Results.data(),
7073 auto *Constructor = dyn_cast<CXXConstructorDecl>(ConstructorD);
7077 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7078 CodeCompleter->getCodeCompletionTUInfo(),
7080 Results.EnterNewScope();
7085 for (
unsigned I = 0,
E = Initializers.size(); I !=
E; ++I) {
7086 if (Initializers[I]->isBaseInitializer())
7087 InitializedBases.insert(getASTContext().getCanonicalType(
7088 QualType(Initializers[I]->getBaseClass(), 0)));
7090 InitializedFields.insert(
7091 cast<FieldDecl>(Initializers[I]->getAnyMember()));
7096 bool SawLastInitializer = Initializers.empty();
7099 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
7101 Results.getCodeCompletionTUInfo());
7102 Builder.AddTypedTextChunk(Name);
7104 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND))
7106 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
7108 FunTemplDecl->getTemplatedDecl(), Builder);
7110 return Builder.TakeString();
7112 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
7115 Results.getCodeCompletionTUInfo());
7116 Builder.AddTypedTextChunk(Name);
7118 Builder.AddPlaceholderChunk(
Type);
7122 Builder.TakeString(), ND,
7124 if (isa<FieldDecl>(ND))
7126 return Results.AddResult(CCR);
7129 Builder.TakeString(),
7133 const char *Name,
const FieldDecl *FD) {
7135 return AddDefaultCtorInit(Name,
7136 FD ? Results.getAllocator().CopyString(
7137 FD->getType().getAsString(Policy))
7141 if (Ctors.begin() == Ctors.end())
7142 return AddDefaultCtorInit(Name, Name, RD);
7146 Results.AddResult(CCR);
7150 const char *BaseName =
7151 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
7152 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
7157 auto AddField = [&](
const FieldDecl *FD) {
7158 const char *FieldName =
7159 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
7160 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
7166 for (
const auto &
Base : ClassDecl->
bases()) {
7167 if (!InitializedBases
7168 .insert(getASTContext().getCanonicalType(
Base.getType()))
7170 SawLastInitializer =
7171 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7172 getASTContext().hasSameUnqualifiedType(
7173 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7178 SawLastInitializer =
false;
7182 for (
const auto &
Base : ClassDecl->
vbases()) {
7183 if (!InitializedBases
7184 .insert(getASTContext().getCanonicalType(
Base.getType()))
7186 SawLastInitializer =
7187 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7188 getASTContext().hasSameUnqualifiedType(
7189 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7194 SawLastInitializer =
false;
7198 for (
auto *Field : ClassDecl->
fields()) {
7199 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
7201 SawLastInitializer = !Initializers.empty() &&
7202 Initializers.back()->isAnyMemberInitializer() &&
7203 Initializers.back()->getAnyMember() == Field;
7207 if (!Field->getDeclName())
7211 SawLastInitializer =
false;
7213 Results.ExitScope();
7216 Results.getCompletionContext(), Results.data(),
7231 bool AfterAmpersand) {
7232 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7233 CodeCompleter->getCodeCompletionTUInfo(),
7235 Results.EnterNewScope();
7239 bool IncludedThis =
false;
7242 IncludedThis =
true;
7251 for (
const auto *
D : S->decls()) {
7252 const auto *Var = dyn_cast<VarDecl>(
D);
7253 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
7256 if (Known.insert(Var->getIdentifier()).second)
7266 Results.ExitScope();
7269 Results.getCompletionContext(), Results.data(),
7276 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7277 CodeCompleter->getCodeCompletionTUInfo(),
7279 auto ShouldAddDefault = [&
D,
this]() {
7280 if (!
D.isFunctionDeclarator())
7282 auto &
Id =
D.getName();
7288 D.getFunctionTypeInfo().NumParams <= 1)
7291 auto Op =
Id.OperatorFunctionId.Operator;
7294 if (Op == OverloadedOperatorKind::OO_Equal)
7296 if (getLangOpts().CPlusPlus20 &&
7297 (Op == OverloadedOperatorKind::OO_EqualEqual ||
7298 Op == OverloadedOperatorKind::OO_ExclaimEqual ||
7299 Op == OverloadedOperatorKind::OO_Less ||
7300 Op == OverloadedOperatorKind::OO_LessEqual ||
7301 Op == OverloadedOperatorKind::OO_Greater ||
7302 Op == OverloadedOperatorKind::OO_GreaterEqual ||
7303 Op == OverloadedOperatorKind::OO_Spaceship))
7309 Results.EnterNewScope();
7310 if (ShouldAddDefault())
7311 Results.AddResult(
"default");
7314 Results.AddResult(
"delete");
7315 Results.ExitScope();
7317 Results.getCompletionContext(), Results.data(),
7323#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
7326 ResultBuilder &Results,
bool NeedAt) {
7332 Results.getCodeCompletionTUInfo());
7333 if (LangOpts.ObjC) {
7337 Builder.AddPlaceholderChunk(
"property");
7338 Results.AddResult(
Result(Builder.TakeString()));
7343 Builder.AddPlaceholderChunk(
"property");
7344 Results.AddResult(
Result(Builder.TakeString()));
7349 ResultBuilder &Results,
bool NeedAt) {
7355 if (LangOpts.ObjC) {
7370 Results.getCodeCompletionTUInfo());
7375 Builder.AddPlaceholderChunk(
"name");
7376 Results.AddResult(
Result(Builder.TakeString()));
7378 if (Results.includeCodePatterns()) {
7384 Builder.AddPlaceholderChunk(
"class");
7385 Results.AddResult(
Result(Builder.TakeString()));
7390 Builder.AddPlaceholderChunk(
"protocol");
7391 Results.AddResult(
Result(Builder.TakeString()));
7396 Builder.AddPlaceholderChunk(
"class");
7397 Results.AddResult(
Result(Builder.TakeString()));
7401 Builder.AddTypedTextChunk(
7404 Builder.AddPlaceholderChunk(
"alias");
7406 Builder.AddPlaceholderChunk(
"class");
7407 Results.AddResult(
Result(Builder.TakeString()));
7409 if (Results.getSema().getLangOpts().Modules) {
7413 Builder.AddPlaceholderChunk(
"module");
7414 Results.AddResult(
Result(Builder.TakeString()));
7419 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7420 CodeCompleter->getCodeCompletionTUInfo(),
7422 Results.EnterNewScope();
7429 Results.ExitScope();
7431 Results.getCompletionContext(), Results.data(),
7438 Results.getCodeCompletionTUInfo());
7441 const char *EncodeType =
"char[]";
7442 if (Results.getSema().getLangOpts().CPlusPlus ||
7443 Results.getSema().getLangOpts().ConstStrings)
7444 EncodeType =
"const char[]";
7445 Builder.AddResultTypeChunk(EncodeType);
7448 Builder.AddPlaceholderChunk(
"type-name");
7450 Results.AddResult(
Result(Builder.TakeString()));
7453 Builder.AddResultTypeChunk(
"Protocol *");
7456 Builder.AddPlaceholderChunk(
"protocol-name");
7458 Results.AddResult(
Result(Builder.TakeString()));
7461 Builder.AddResultTypeChunk(
"SEL");
7464 Builder.AddPlaceholderChunk(
"selector");
7466 Results.AddResult(
Result(Builder.TakeString()));
7469 Builder.AddResultTypeChunk(
"NSString *");
7471 Builder.AddPlaceholderChunk(
"string");
7472 Builder.AddTextChunk(
"\"");
7473 Results.AddResult(
Result(Builder.TakeString()));
7476 Builder.AddResultTypeChunk(
"NSArray *");
7478 Builder.AddPlaceholderChunk(
"objects, ...");
7480 Results.AddResult(
Result(Builder.TakeString()));
7483 Builder.AddResultTypeChunk(
"NSDictionary *");
7485 Builder.AddPlaceholderChunk(
"key");
7488 Builder.AddPlaceholderChunk(
"object, ...");
7490 Results.AddResult(
Result(Builder.TakeString()));
7493 Builder.AddResultTypeChunk(
"id");
7495 Builder.AddPlaceholderChunk(
"expression");
7497 Results.AddResult(
Result(Builder.TakeString()));
7503 Results.getCodeCompletionTUInfo());
7505 if (Results.includeCodePatterns()) {
7510 Builder.AddPlaceholderChunk(
"statements");
7512 Builder.AddTextChunk(
"@catch");
7514 Builder.AddPlaceholderChunk(
"parameter");
7517 Builder.AddPlaceholderChunk(
"statements");
7519 Builder.AddTextChunk(
"@finally");
7521 Builder.AddPlaceholderChunk(
"statements");
7523 Results.AddResult(
Result(Builder.TakeString()));
7529 Builder.AddPlaceholderChunk(
"expression");
7530 Results.AddResult(
Result(Builder.TakeString()));
7532 if (Results.includeCodePatterns()) {
7537 Builder.AddPlaceholderChunk(
"expression");
7540 Builder.AddPlaceholderChunk(
"statements");
7542 Results.AddResult(
Result(Builder.TakeString()));
7547 ResultBuilder &Results,
bool NeedAt) {
7557 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7558 CodeCompleter->getCodeCompletionTUInfo(),
7560 Results.EnterNewScope();
7562 Results.ExitScope();
7564 Results.getCompletionContext(), Results.data(),
7569 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7570 CodeCompleter->getCodeCompletionTUInfo(),
7572 Results.EnterNewScope();
7575 Results.ExitScope();
7577 Results.getCompletionContext(), Results.data(),
7582 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7583 CodeCompleter->getCodeCompletionTUInfo(),
7585 Results.EnterNewScope();
7587 Results.ExitScope();
7589 Results.getCompletionContext(), Results.data(),
7597 if (Attributes & NewFlag)
7600 Attributes |= NewFlag;
7608 unsigned AssignCopyRetMask =
7614 if (AssignCopyRetMask &&
7633 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7634 CodeCompleter->getCodeCompletionTUInfo(),
7636 Results.EnterNewScope();
7673 Results.getCodeCompletionTUInfo());
7682 Results.getCodeCompletionTUInfo());
7695 Results.ExitScope();
7697 Results.getCompletionContext(), Results.data(),
7711 bool AllowSameLength =
true) {
7712 unsigned NumSelIdents = SelIdents.size();
7725 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
7728 for (
unsigned I = 0; I != NumSelIdents; ++I)
7738 bool AllowSameLength =
true) {
7772 ResultBuilder &Results,
bool InOriginalClass =
true,
7773 bool IsRootClass =
false) {
7777 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
7781 if (M->isInstanceMethod() == WantInstanceMethods ||
7782 (IsRootClass && !WantInstanceMethods)) {
7788 if (!Selectors.insert(M->getSelector()).second)
7791 Result R =
Result(M, Results.getBasePriority(M),
nullptr);
7792 R.StartParameter = SelIdents.size();
7793 R.AllParametersAreInformative = (WantKind !=
MK_Any);
7794 if (!InOriginalClass)
7796 Results.MaybeAddResult(R, CurContext);
7801 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
7802 if (Protocol->hasDefinition()) {
7804 Protocol->getReferencedProtocols();
7806 E = Protocols.
end();
7808 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7809 Selectors, AllowSameLength, Results,
false, IsRootClass);
7818 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7819 Selectors, AllowSameLength, Results,
false, IsRootClass);
7823 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
7824 CurContext, Selectors, AllowSameLength, Results,
7825 InOriginalClass, IsRootClass);
7829 CatDecl->getReferencedProtocols();
7831 E = Protocols.
end();
7833 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7834 Selectors, AllowSameLength, Results,
false, IsRootClass);
7838 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7839 Selectors, AllowSameLength, Results, InOriginalClass,
7847 SelIdents, CurContext, Selectors, AllowSameLength, Results,
7852 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7853 Selectors, AllowSameLength, Results, InOriginalClass,
7860 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7863 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7871 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7872 CodeCompleter->getCodeCompletionTUInfo(),
7874 Results.EnterNewScope();
7880 Results.ExitScope();
7882 Results.getCompletionContext(), Results.data(),
7889 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7892 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7900 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7901 CodeCompleter->getCodeCompletionTUInfo(),
7903 Results.EnterNewScope();
7910 Results.ExitScope();
7912 Results.getCompletionContext(), Results.data(),
7918 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7919 CodeCompleter->getCodeCompletionTUInfo(),
7921 Results.EnterNewScope();
7924 bool AddedInOut =
false;
7927 Results.AddResult(
"in");
7928 Results.AddResult(
"inout");
7933 Results.AddResult(
"out");
7935 Results.AddResult(
"inout");
7940 Results.AddResult(
"bycopy");
7941 Results.AddResult(
"byref");
7942 Results.AddResult(
"oneway");
7945 Results.AddResult(
"nonnull");
7946 Results.AddResult(
"nullable");
7947 Results.AddResult(
"null_unspecified");
7957 Results.getCodeCompletionTUInfo(),
7959 Builder.AddTypedTextChunk(
"IBAction");
7961 Builder.AddPlaceholderChunk(
"selector");
7964 Builder.AddTextChunk(
"id");
7966 Builder.AddTextChunk(
"sender");
7977 Results.ExitScope();
7980 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
7981 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7983 CodeCompleter->includeGlobals(),
7984 CodeCompleter->loadExternal());
7986 if (CodeCompleter->includeMacros())
7990 Results.getCompletionContext(), Results.data(),
7999 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(
E);
8017 switch (Msg->getReceiverKind()) {
8021 IFace = ObjType->getInterface();
8025 QualType T = Msg->getInstanceReceiver()->getType();
8027 IFace = Ptr->getInterfaceDecl();
8041 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
8042 .Case(
"retain", IFace)
8043 .Case(
"strong", IFace)
8044 .Case(
"autorelease", IFace)
8045 .Case(
"copy", IFace)
8046 .Case(
"copyWithZone", IFace)
8047 .Case(
"mutableCopy", IFace)
8048 .Case(
"mutableCopyWithZone", IFace)
8049 .Case(
"awakeFromCoder", IFace)
8050 .Case(
"replacementObjectFromCoder", IFace)
8051 .Case(
"class", IFace)
8052 .Case(
"classForCoder", IFace)
8053 .Case(
"superclass", Super)
8056 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
8058 .Case(
"alloc", IFace)
8059 .Case(
"allocWithZone", IFace)
8060 .Case(
"class", IFace)
8061 .Case(
"superclass", Super)
8084 ResultBuilder &Results) {
8095 while ((
Class =
Class->getSuperClass()) && !SuperMethod) {
8102 for (
const auto *Cat :
Class->known_categories()) {
8103 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
8121 CurP != CurPEnd; ++CurP, ++SuperP) {
8124 (*SuperP)->getType()))
8128 if (!(*CurP)->getIdentifier())
8134 Results.getCodeCompletionTUInfo());
8138 Results.getCompletionContext().getBaseType(), Builder);
8141 if (NeedSuperKeyword) {
8142 Builder.AddTypedTextChunk(
"super");
8148 if (NeedSuperKeyword)
8149 Builder.AddTextChunk(
8152 Builder.AddTypedTextChunk(
8156 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
8157 if (I > SelIdents.size())
8160 if (I < SelIdents.size())
8161 Builder.AddInformativeChunk(
8163 else if (NeedSuperKeyword || I > SelIdents.size()) {
8164 Builder.AddTextChunk(
8166 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8167 (*CurP)->getIdentifier()->getName()));
8169 Builder.AddTypedTextChunk(
8171 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8172 (*CurP)->getIdentifier()->getName()));
8184 ResultBuilder Results(
8185 SemaRef, CodeCompleter->getAllocator(),
8186 CodeCompleter->getCodeCompletionTUInfo(),
8189 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
8190 : &ResultBuilder::IsObjCMessageReceiver);
8192 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
8193 Results.EnterNewScope();
8195 CodeCompleter->includeGlobals(),
8196 CodeCompleter->loadExternal());
8202 if (Iface->getSuperClass()) {
8203 Results.AddResult(
Result(
"super"));
8211 Results.ExitScope();
8213 if (CodeCompleter->includeMacros())
8216 Results.getCompletionContext(), Results.data(),
8226 CDecl = CurMethod->getClassInterface();
8235 if (CurMethod->isInstanceMethod()) {
8239 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
8240 AtArgumentExpression, CDecl);
8250 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
8252 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
8254 getASTContext().getTypeDeclType(TD)->getAs<ObjCObjectType>())
8255 CDecl = Iface->getInterface();
8256 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
8268 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
8269 SelIdents, AtArgumentExpression);
8278 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
8279 AtArgumentExpression,
8286 unsigned NumSelIdents) {
8288 ASTContext &Context = Results.getSema().Context;
8292 Result *ResultsData = Results.data();
8293 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
8294 Result &R = ResultsData[I];
8295 if (R.Kind == Result::RK_Declaration &&
8296 isa<ObjCMethodDecl>(R.Declaration)) {
8297 if (R.Priority <= BestPriority) {
8298 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
8299 if (NumSelIdents <= Method->param_size()) {
8301 Method->
parameters()[NumSelIdents - 1]->getType();
8302 if (R.Priority < BestPriority || PreferredType.
isNull()) {
8303 BestPriority = R.Priority;
8304 PreferredType = MyPreferredType;
8314 return PreferredType;
8320 bool AtArgumentExpression,
bool IsSuper,
8321 ResultBuilder &Results) {
8336 Results.EnterNewScope();
8343 Results.Ignore(SuperMethod);
8349 Results.setPreferredSelector(CurMethod->getSelector());
8354 Selectors, AtArgumentExpression, Results);
8361 for (uint32_t I = 0,
8372 for (SemaObjC::GlobalMethodPool::iterator
8377 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8381 Result R(MethList->getMethod(),
8382 Results.getBasePriority(MethList->getMethod()),
nullptr);
8383 R.StartParameter = SelIdents.size();
8384 R.AllParametersAreInformative =
false;
8385 Results.MaybeAddResult(R, SemaRef.
CurContext);
8390 Results.ExitScope();
8395 bool AtArgumentExpression,
bool IsSuper) {
8399 ResultBuilder Results(
8400 SemaRef, CodeCompleter->getAllocator(),
8401 CodeCompleter->getCodeCompletionTUInfo(),
8406 AtArgumentExpression, IsSuper, Results);
8413 if (AtArgumentExpression) {
8416 if (PreferredType.
isNull())
8417 CodeCompleteOrdinaryName(S, PCC_Expression);
8419 CodeCompleteExpression(S, PreferredType);
8424 Results.getCompletionContext(), Results.data(),
8434 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
8442 RecExpr = Conv.
get();
8456 return CodeCompleteObjCClassMessage(
8458 AtArgumentExpression, Super);
8463 }
else if (RecExpr && getLangOpts().CPlusPlus) {
8466 RecExpr = Conv.
get();
8467 ReceiverType = RecExpr->
getType();
8472 ResultBuilder Results(
8473 SemaRef, CodeCompleter->getAllocator(),
8474 CodeCompleter->getCodeCompletionTUInfo(),
8476 ReceiverType, SelIdents));
8478 Results.EnterNewScope();
8485 Results.Ignore(SuperMethod);
8491 Results.setPreferredSelector(CurMethod->getSelector());
8504 Selectors, AtArgumentExpression, Results);
8511 for (
auto *I : QualID->quals())
8513 AtArgumentExpression, Results);
8520 SemaRef.
CurContext, Selectors, AtArgumentExpression,
8524 for (
auto *I : IFacePtr->quals())
8526 AtArgumentExpression, Results);
8536 for (uint32_t I = 0,
8547 for (SemaObjC::GlobalMethodPool::iterator
8552 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8556 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
8559 Result R(MethList->getMethod(),
8560 Results.getBasePriority(MethList->getMethod()),
nullptr);
8561 R.StartParameter = SelIdents.size();
8562 R.AllParametersAreInformative =
false;
8563 Results.MaybeAddResult(R, SemaRef.
CurContext);
8567 Results.ExitScope();
8574 if (AtArgumentExpression) {
8577 if (PreferredType.
isNull())
8578 CodeCompleteOrdinaryName(S, PCC_Expression);
8580 CodeCompleteExpression(S, PreferredType);
8585 Results.getCompletionContext(), Results.data(),
8592 Data.ObjCCollection =
true;
8598 Data.IgnoreDecls.push_back(*I);
8602 CodeCompleteExpression(S,
Data);
8610 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
8620 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8621 CodeCompleter->getCodeCompletionTUInfo(),
8623 Results.EnterNewScope();
8624 for (SemaObjC::GlobalMethodPool::iterator
8634 Results.getCodeCompletionTUInfo());
8636 Builder.AddTypedTextChunk(
8638 Results.AddResult(Builder.TakeString());
8642 std::string Accumulator;
8643 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
8644 if (I == SelIdents.size()) {
8645 if (!Accumulator.empty()) {
8646 Builder.AddInformativeChunk(
8647 Builder.getAllocator().CopyString(Accumulator));
8648 Accumulator.clear();
8655 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
8656 Results.AddResult(Builder.TakeString());
8658 Results.ExitScope();
8661 Results.getCompletionContext(), Results.data(),
8668 bool OnlyForwardDeclarations,
8669 ResultBuilder &Results) {
8672 for (
const auto *
D : Ctx->
decls()) {
8674 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(
D))
8675 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
8677 Result(Proto, Results.getBasePriority(Proto),
nullptr), CurContext,
8684 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8685 CodeCompleter->getCodeCompletionTUInfo(),
8688 if (CodeCompleter->includeGlobals()) {
8689 Results.EnterNewScope();
8697 Results.Ignore(Protocol);
8703 Results.ExitScope();
8707 Results.getCompletionContext(), Results.data(),
8712 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8713 CodeCompleter->getCodeCompletionTUInfo(),
8716 if (CodeCompleter->includeGlobals()) {
8717 Results.EnterNewScope();
8723 Results.ExitScope();
8727 Results.getCompletionContext(), Results.data(),
8734 bool OnlyForwardDeclarations,
8735 bool OnlyUnimplemented,
8736 ResultBuilder &Results) {
8739 for (
const auto *
D : Ctx->
decls()) {
8741 if (
const auto *
Class = dyn_cast<ObjCInterfaceDecl>(
D))
8742 if ((!OnlyForwardDeclarations || !
Class->hasDefinition()) &&
8743 (!OnlyUnimplemented || !
Class->getImplementation()))
8751 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8752 CodeCompleter->getCodeCompletionTUInfo(),
8754 Results.EnterNewScope();
8756 if (CodeCompleter->includeGlobals()) {
8762 Results.ExitScope();
8765 Results.getCompletionContext(), Results.data(),
8770 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8771 CodeCompleter->getCodeCompletionTUInfo(),
8773 Results.EnterNewScope();
8775 if (CodeCompleter->includeGlobals()) {
8781 Results.ExitScope();
8784 Results.getCompletionContext(), Results.data(),
8790 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8791 CodeCompleter->getCodeCompletionTUInfo(),
8793 Results.EnterNewScope();
8798 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
8799 Results.Ignore(CurClass);
8801 if (CodeCompleter->includeGlobals()) {
8807 Results.ExitScope();
8810 Results.getCompletionContext(), Results.data(),
8815 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8816 CodeCompleter->getCodeCompletionTUInfo(),
8818 Results.EnterNewScope();
8820 if (CodeCompleter->includeGlobals()) {
8826 Results.ExitScope();
8829 Results.getCompletionContext(), Results.data(),
8837 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8838 CodeCompleter->getCodeCompletionTUInfo(),
8847 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
8848 for (
const auto *Cat :
Class->visible_categories())
8849 CategoryNames.insert(Cat->getIdentifier());
8853 Results.EnterNewScope();
8855 for (
const auto *
D : TU->
decls())
8856 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(
D))
8857 if (CategoryNames.insert(
Category->getIdentifier()).second)
8861 Results.ExitScope();
8864 Results.getCompletionContext(), Results.data(),
8879 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
8881 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8882 CodeCompleter->getCodeCompletionTUInfo(),
8889 Results.EnterNewScope();
8890 bool IgnoreImplemented =
true;
8892 for (
const auto *Cat :
Class->visible_categories()) {
8893 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
8894 CategoryNames.insert(Cat->getIdentifier()).second)
8895 Results.AddResult(
Result(Cat, Results.getBasePriority(Cat),
nullptr),
8900 IgnoreImplemented =
false;
8902 Results.ExitScope();
8905 Results.getCompletionContext(), Results.data(),
8911 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8912 CodeCompleter->getCodeCompletionTUInfo(), CCContext);
8916 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8917 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8918 !isa<ObjCCategoryImplDecl>(Container)))
8923 for (
const auto *
D : Container->decls())
8924 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(
D))
8925 Results.Ignore(PropertyImpl->getPropertyDecl());
8929 Results.EnterNewScope();
8931 dyn_cast<ObjCImplementationDecl>(Container))
8934 AddedProperties, Results);
8937 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
8939 AddedProperties, Results);
8940 Results.ExitScope();
8943 Results.getCompletionContext(), Results.data(),
8950 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8951 CodeCompleter->getCodeCompletionTUInfo(),
8956 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8957 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8958 !isa<ObjCCategoryImplDecl>(Container)))
8964 dyn_cast<ObjCImplementationDecl>(Container))
8965 Class = ClassImpl->getClassInterface();
8967 Class = cast<ObjCCategoryImplDecl>(Container)
8969 ->getClassInterface();
8972 QualType PropertyType = getASTContext().getObjCIdType();
8977 Property->getType().getNonReferenceType().getUnqualifiedType();
8980 Results.setPreferredType(PropertyType);
8985 Results.EnterNewScope();
8986 bool SawSimilarlyNamedIvar =
false;
8987 std::string NameWithPrefix;
8988 NameWithPrefix +=
'_';
8989 NameWithPrefix += PropertyName->getName();
8990 std::string NameWithSuffix = PropertyName->getName().str();
8991 NameWithSuffix +=
'_';
8994 Ivar = Ivar->getNextIvar()) {
8995 Results.AddResult(
Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
9000 if ((PropertyName == Ivar->getIdentifier() ||
9001 NameWithPrefix == Ivar->getName() ||
9002 NameWithSuffix == Ivar->getName())) {
9003 SawSimilarlyNamedIvar =
true;
9007 if (Results.size() &&
9008 Results.data()[Results.size() - 1].Kind ==
9010 Results.data()[Results.size() - 1].Declaration == Ivar)
9011 Results.data()[Results.size() - 1].Priority--;
9016 if (!SawSimilarlyNamedIvar) {
9027 PropertyType, getASTContext(), Policy, Allocator));
9028 Builder.AddTypedTextChunk(Allocator.CopyString(NameWithPrefix));
9033 Results.ExitScope();
9036 Results.getCompletionContext(), Results.data(),
9043 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
9052 std::optional<bool> WantInstanceMethods,
9055 bool InOriginalClass =
true) {
9058 if (!IFace->hasDefinition())
9061 IFace = IFace->getDefinition();
9065 IFace->getReferencedProtocols();
9067 E = Protocols.
end();
9070 KnownMethods, InOriginalClass);
9073 for (
auto *Cat : IFace->visible_categories()) {
9075 KnownMethods,
false);
9079 if (IFace->getSuperClass())
9081 WantInstanceMethods, ReturnType, KnownMethods,
9088 Category->getReferencedProtocols();
9090 E = Protocols.
end();
9093 KnownMethods, InOriginalClass);
9096 if (InOriginalClass &&
Category->getClassInterface())
9098 WantInstanceMethods, ReturnType, KnownMethods,
9104 if (!Protocol->hasDefinition())
9106 Protocol = Protocol->getDefinition();
9107 Container = Protocol;
9111 Protocol->getReferencedProtocols();
9113 E = Protocols.
end();
9116 KnownMethods,
false);
9122 for (
auto *M : Container->methods()) {
9123 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
9124 if (!ReturnType.
isNull() &&
9128 KnownMethods[M->getSelector()] =
9129 KnownMethodsMap::mapped_type(M, InOriginalClass);
9143 Builder.AddTextChunk(Builder.getAllocator().CopyString(Quals));
9144 Builder.AddTextChunk(
9155 if (
Class->getIdentifier() &&
Class->getIdentifier()->getName() == Name)
9164 bool IsInstanceMethod,
9167 ResultBuilder &Results) {
9169 if (!PropName || PropName->
getLength() == 0)
9187 const char *CopiedKey;
9190 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
9192 operator const char *() {
9196 return CopiedKey = Allocator.CopyString(Key);
9198 } Key(Allocator, PropName->
getName());
9201 std::string UpperKey = std::string(PropName->
getName());
9202 if (!UpperKey.empty())
9205 bool ReturnTypeMatchesProperty =
9209 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
9212 if (IsInstanceMethod &&
9214 ReturnTypeMatchesProperty && !
Property->getGetterMethodDecl()) {
9219 Builder.AddTypedTextChunk(Key);
9226 if (IsInstanceMethod &&
9227 ((!ReturnType.
isNull() &&
9230 Property->getType()->isBooleanType())))) {
9231 std::string SelectorName = (Twine(
"is") + UpperKey).str();
9235 if (ReturnType.
isNull()) {
9237 Builder.AddTextChunk(
"BOOL");
9241 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9248 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
9249 !
Property->getSetterMethodDecl()) {
9250 std::string SelectorName = (Twine(
"set") + UpperKey).str();
9252 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9253 if (ReturnType.
isNull()) {
9255 Builder.AddTextChunk(
"void");
9259 Builder.AddTypedTextChunk(
9260 Allocator.CopyString(SelectorId->
getName() +
":"));
9263 Builder.AddTextChunk(Key);
9274 if (
const auto *ObjCPointer =
9299 if (IsInstanceMethod &&
9301 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
9305 if (ReturnType.
isNull()) {
9307 Builder.AddTextChunk(
"NSUInteger");
9311 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9313 Result(Builder.TakeString(),
9314 std::min(IndexedGetterPriority, UnorderedGetterPriority),
9321 if (IsInstanceMethod &&
9323 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
9325 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9326 if (ReturnType.
isNull()) {
9328 Builder.AddTextChunk(
"id");
9332 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9334 Builder.AddTextChunk(
"NSUInteger");
9336 Builder.AddTextChunk(
"index");
9337 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9343 if (IsInstanceMethod &&
9350 std::string SelectorName = (Twine(
Property->getName()) +
"AtIndexes").str();
9352 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9353 if (ReturnType.
isNull()) {
9355 Builder.AddTextChunk(
"NSArray *");
9359 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9361 Builder.AddTextChunk(
"NSIndexSet *");
9363 Builder.AddTextChunk(
"indexes");
9364 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9370 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9371 std::string SelectorName = (Twine(
"get") + UpperKey).str();
9375 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9376 if (ReturnType.
isNull()) {
9378 Builder.AddTextChunk(
"void");
9382 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9384 Builder.AddPlaceholderChunk(
"object-type");
9385 Builder.AddTextChunk(
" **");
9387 Builder.AddTextChunk(
"buffer");
9389 Builder.AddTypedTextChunk(
"range:");
9391 Builder.AddTextChunk(
"NSRange");
9393 Builder.AddTextChunk(
"inRange");
9394 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9402 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9403 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
9407 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9408 if (ReturnType.
isNull()) {
9410 Builder.AddTextChunk(
"void");
9414 Builder.AddTypedTextChunk(
"insertObject:");
9416 Builder.AddPlaceholderChunk(
"object-type");
9417 Builder.AddTextChunk(
" *");
9419 Builder.AddTextChunk(
"object");
9421 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9423 Builder.AddPlaceholderChunk(
"NSUInteger");
9425 Builder.AddTextChunk(
"index");
9426 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9432 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9433 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
9437 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9438 if (ReturnType.
isNull()) {
9440 Builder.AddTextChunk(
"void");
9444 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9446 Builder.AddTextChunk(
"NSArray *");
9448 Builder.AddTextChunk(
"array");
9450 Builder.AddTypedTextChunk(
"atIndexes:");
9452 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9454 Builder.AddTextChunk(
"indexes");
9455 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9461 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9462 std::string SelectorName =
9463 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
9465 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9466 if (ReturnType.
isNull()) {
9468 Builder.AddTextChunk(
"void");
9472 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9474 Builder.AddTextChunk(
"NSUInteger");
9476 Builder.AddTextChunk(
"index");
9477 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9483 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9484 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
9486 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9487 if (ReturnType.
isNull()) {
9489 Builder.AddTextChunk(
"void");
9493 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9495 Builder.AddTextChunk(
"NSIndexSet *");
9497 Builder.AddTextChunk(
"indexes");
9498 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9504 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9505 std::string SelectorName =
9506 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
9510 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9511 if (ReturnType.
isNull()) {
9513 Builder.AddTextChunk(
"void");
9517 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9519 Builder.AddPlaceholderChunk(
"NSUInteger");
9521 Builder.AddTextChunk(
"index");
9523 Builder.AddTypedTextChunk(
"withObject:");
9525 Builder.AddTextChunk(
"id");
9527 Builder.AddTextChunk(
"object");
9528 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9534 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9535 std::string SelectorName1 =
9536 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
9537 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
9541 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9542 if (ReturnType.
isNull()) {
9544 Builder.AddTextChunk(
"void");
9548 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName1 +
":"));
9550 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9552 Builder.AddTextChunk(
"indexes");
9554 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName2 +
":"));
9556 Builder.AddTextChunk(
"NSArray *");
9558 Builder.AddTextChunk(
"array");
9559 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9566 if (IsInstanceMethod &&
9572 ->
getName() ==
"NSEnumerator"))) {
9573 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
9577 if (ReturnType.
isNull()) {
9579 Builder.AddTextChunk(
"NSEnumerator *");
9583 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9584 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9590 if (IsInstanceMethod &&
9592 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
9594 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9595 if (ReturnType.
isNull()) {
9597 Builder.AddPlaceholderChunk(
"object-type");
9598 Builder.AddTextChunk(
" *");
9602 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9604 if (ReturnType.
isNull()) {
9605 Builder.AddPlaceholderChunk(
"object-type");
9606 Builder.AddTextChunk(
" *");
9609 ReturnType, Context, Policy, Builder.getAllocator()));
9612 Builder.AddTextChunk(
"object");
9613 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9620 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9621 std::string SelectorName =
9622 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
9624 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9625 if (ReturnType.
isNull()) {
9627 Builder.AddTextChunk(
"void");
9631 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9633 Builder.AddPlaceholderChunk(
"object-type");
9634 Builder.AddTextChunk(
" *");
9636 Builder.AddTextChunk(
"object");
9637 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9643 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9644 std::string SelectorName = (Twine(
"add") + UpperKey).str();
9646 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9647 if (ReturnType.
isNull()) {
9649 Builder.AddTextChunk(
"void");
9653 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9655 Builder.AddTextChunk(
"NSSet *");
9657 Builder.AddTextChunk(
"objects");
9658 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9664 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9665 std::string SelectorName =
9666 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
9668 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9669 if (ReturnType.
isNull()) {
9671 Builder.AddTextChunk(
"void");
9675 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9677 Builder.AddPlaceholderChunk(
"object-type");
9678 Builder.AddTextChunk(
" *");
9680 Builder.AddTextChunk(
"object");
9681 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9687 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9688 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
9690 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9691 if (ReturnType.
isNull()) {
9693 Builder.AddTextChunk(
"void");
9697 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9699 Builder.AddTextChunk(
"NSSet *");
9701 Builder.AddTextChunk(
"objects");
9702 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9708 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9709 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
9711 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9712 if (ReturnType.
isNull()) {
9714 Builder.AddTextChunk(
"void");
9718 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9720 Builder.AddTextChunk(
"NSSet *");
9722 Builder.AddTextChunk(
"objects");
9723 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9730 if (!IsInstanceMethod &&
9737 std::string SelectorName =
9738 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
9742 if (ReturnType.
isNull()) {
9744 Builder.AddTextChunk(
"NSSet<NSString *> *");
9748 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9755 if (!IsInstanceMethod &&
9758 std::string SelectorName =
9759 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
9763 if (ReturnType.
isNull()) {
9765 Builder.AddTextChunk(
"BOOL");
9769 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9777 Scope *S, std::optional<bool> IsInstanceMethod,
ParsedType ReturnTy) {
9782 Decl *IDecl =
nullptr;
9789 bool IsInImplementation =
false;
9790 if (
Decl *
D = IDecl) {
9792 SearchDecl = Impl->getClassInterface();
9793 IsInImplementation =
true;
9795 dyn_cast<ObjCCategoryImplDecl>(
D)) {
9796 SearchDecl = CatImpl->getCategoryDecl();
9797 IsInImplementation =
true;
9799 SearchDecl = dyn_cast<ObjCContainerDecl>(
D);
9802 if (!SearchDecl && S) {
9804 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
9820 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9821 CodeCompleter->getCodeCompletionTUInfo(),
9823 Results.EnterNewScope();
9825 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9826 MEnd = KnownMethods.end();
9830 Results.getCodeCompletionTUInfo());
9833 if (!IsInstanceMethod) {
9840 if (ReturnType.
isNull()) {
9851 Builder.AddTypedTextChunk(
9858 P != PEnd; (
void)++
P, ++I) {
9861 Builder.AddTypedTextChunk(
9865 Builder.AddTypedTextChunk(
9873 ParamType = (*P)->getType();
9875 ParamType = (*P)->getOriginalType();
9880 Context, Policy, Builder);
9883 Builder.AddTextChunk(
9884 Builder.getAllocator().CopyString(
Id->getName()));
9891 Builder.AddTextChunk(
"...");
9894 if (IsInImplementation && Results.includeCodePatterns()) {
9901 Builder.AddTextChunk(
"return");
9903 Builder.AddPlaceholderChunk(
"expression");
9906 Builder.AddPlaceholderChunk(
"statements");
9914 if (!M->second.getInt())
9916 Results.AddResult(std::move(R));
9923 Containers.push_back(SearchDecl);
9926 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9927 MEnd = KnownMethods.end();
9929 KnownSelectors.insert(M->first);
9934 IFace =
Category->getClassInterface();
9939 if (IsInstanceMethod) {
9940 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
9941 for (
auto *
P : Containers[I]->instance_properties())
9943 KnownSelectors, Results);
9947 Results.ExitScope();
9950 Results.getCompletionContext(), Results.data(),
9955 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
9960 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
9972 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9973 CodeCompleter->getCodeCompletionTUInfo(),
9977 Results.setPreferredType(
9980 Results.EnterNewScope();
9981 for (SemaObjC::GlobalMethodPool::iterator
9985 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
9986 : &M->second.second;
9987 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
9991 if (AtParameterName) {
9993 unsigned NumSelIdents = SelIdents.size();
9995 NumSelIdents <= MethList->getMethod()->param_size()) {
9997 MethList->getMethod()->parameters()[NumSelIdents - 1];
10000 Results.getCodeCompletionTUInfo());
10001 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
10003 Results.AddResult(Builder.TakeString());
10010 Result R(MethList->getMethod(),
10011 Results.getBasePriority(MethList->getMethod()),
nullptr);
10012 R.StartParameter = SelIdents.size();
10013 R.AllParametersAreInformative =
false;
10014 R.DeclaringEntity =
true;
10015 Results.MaybeAddResult(R, SemaRef.
CurContext);
10019 Results.ExitScope();
10021 if (!AtParameterName && !SelIdents.empty() &&
10022 SelIdents.front()->getName().starts_with(
"init")) {
10023 for (
const auto &M : SemaRef.
PP.
macros()) {
10024 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
10026 Results.EnterNewScope();
10028 Results.getCodeCompletionTUInfo());
10029 Builder.AddTypedTextChunk(
10030 Builder.getAllocator().CopyString(M.first->getName()));
10033 Results.ExitScope();
10038 Results.getCompletionContext(), Results.data(),
10043 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10044 CodeCompleter->getCodeCompletionTUInfo(),
10046 Results.EnterNewScope();
10050 Results.getCodeCompletionTUInfo());
10051 Builder.AddTypedTextChunk(
"if");
10053 Builder.AddPlaceholderChunk(
"condition");
10054 Results.AddResult(Builder.TakeString());
10057 Builder.AddTypedTextChunk(
"ifdef");
10059 Builder.AddPlaceholderChunk(
"macro");
10060 Results.AddResult(Builder.TakeString());
10063 Builder.AddTypedTextChunk(
"ifndef");
10065 Builder.AddPlaceholderChunk(
"macro");
10066 Results.AddResult(Builder.TakeString());
10068 if (InConditional) {
10070 Builder.AddTypedTextChunk(
"elif");
10072 Builder.AddPlaceholderChunk(
"condition");
10073 Results.AddResult(Builder.TakeString());
10076 Builder.AddTypedTextChunk(
"elifdef");
10078 Builder.AddPlaceholderChunk(
"macro");
10079 Results.AddResult(Builder.TakeString());
10082 Builder.AddTypedTextChunk(
"elifndef");
10084 Builder.AddPlaceholderChunk(
"macro");
10085 Results.AddResult(Builder.TakeString());
10088 Builder.AddTypedTextChunk(
"else");
10089 Results.AddResult(Builder.TakeString());
10092 Builder.AddTypedTextChunk(
"endif");
10093 Results.AddResult(Builder.TakeString());
10097 Builder.AddTypedTextChunk(
"include");
10099 Builder.AddTextChunk(
"\"");
10100 Builder.AddPlaceholderChunk(
"header");
10101 Builder.AddTextChunk(
"\"");
10102 Results.AddResult(Builder.TakeString());
10105 Builder.AddTypedTextChunk(
"include");
10107 Builder.AddTextChunk(
"<");
10108 Builder.AddPlaceholderChunk(
"header");
10109 Builder.AddTextChunk(
">");
10110 Results.AddResult(Builder.TakeString());
10113 Builder.AddTypedTextChunk(
"define");
10115 Builder.AddPlaceholderChunk(
"macro");
10116 Results.AddResult(Builder.TakeString());
10119 Builder.AddTypedTextChunk(
"define");
10121 Builder.AddPlaceholderChunk(
"macro");
10123 Builder.AddPlaceholderChunk(
"args");
10125 Results.AddResult(Builder.TakeString());
10128 Builder.AddTypedTextChunk(
"undef");
10130 Builder.AddPlaceholderChunk(
"macro");
10131 Results.AddResult(Builder.TakeString());
10134 Builder.AddTypedTextChunk(
"line");
10136 Builder.AddPlaceholderChunk(
"number");
10137 Results.AddResult(Builder.TakeString());
10140 Builder.AddTypedTextChunk(
"line");
10142 Builder.AddPlaceholderChunk(
"number");
10144 Builder.AddTextChunk(
"\"");
10145 Builder.AddPlaceholderChunk(
"filename");
10146 Builder.AddTextChunk(
"\"");
10147 Results.AddResult(Builder.TakeString());
10150 Builder.AddTypedTextChunk(
"error");
10152 Builder.AddPlaceholderChunk(
"message");
10153 Results.AddResult(Builder.TakeString());
10156 Builder.AddTypedTextChunk(
"pragma");
10158 Builder.AddPlaceholderChunk(
"arguments");
10159 Results.AddResult(Builder.TakeString());
10161 if (getLangOpts().
ObjC) {
10163 Builder.AddTypedTextChunk(
"import");
10165 Builder.AddTextChunk(
"\"");
10166 Builder.AddPlaceholderChunk(
"header");
10167 Builder.AddTextChunk(
"\"");
10168 Results.AddResult(Builder.TakeString());
10171 Builder.AddTypedTextChunk(
"import");
10173 Builder.AddTextChunk(
"<");
10174 Builder.AddPlaceholderChunk(
"header");
10175 Builder.AddTextChunk(
">");
10176 Results.AddResult(Builder.TakeString());
10180 Builder.AddTypedTextChunk(
"include_next");
10182 Builder.AddTextChunk(
"\"");
10183 Builder.AddPlaceholderChunk(
"header");
10184 Builder.AddTextChunk(
"\"");
10185 Results.AddResult(Builder.TakeString());
10188 Builder.AddTypedTextChunk(
"include_next");
10190 Builder.AddTextChunk(
"<");
10191 Builder.AddPlaceholderChunk(
"header");
10192 Builder.AddTextChunk(
">");
10193 Results.AddResult(Builder.TakeString());
10196 Builder.AddTypedTextChunk(
"warning");
10198 Builder.AddPlaceholderChunk(
"message");
10199 Results.AddResult(Builder.TakeString());
10206 Results.ExitScope();
10209 Results.getCompletionContext(), Results.data(),
10215 CodeCompleteOrdinaryName(S, S->getFnParent()
10221 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10222 CodeCompleter->getCodeCompletionTUInfo(),
10225 if (!IsDefinition && CodeCompleter->includeMacros()) {
10228 Results.getCodeCompletionTUInfo());
10229 Results.EnterNewScope();
10233 Builder.AddTypedTextChunk(
10234 Builder.getAllocator().CopyString(M->first->getName()));
10238 Results.ExitScope();
10239 }
else if (IsDefinition) {
10244 Results.getCompletionContext(), Results.data(),
10249 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10250 CodeCompleter->getCodeCompletionTUInfo(),
10253 if (CodeCompleter->includeMacros())
10257 Results.EnterNewScope();
10259 Results.getCodeCompletionTUInfo());
10260 Builder.AddTypedTextChunk(
"defined");
10263 Builder.AddPlaceholderChunk(
"macro");
10265 Results.AddResult(Builder.TakeString());
10266 Results.ExitScope();
10269 Results.getCompletionContext(), Results.data(),
10289 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
10292 llvm::sys::path::native(NativeRelDir);
10293 llvm::vfs::FileSystem &FS =
10296 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10297 CodeCompleter->getCodeCompletionTUInfo(),
10299 llvm::DenseSet<StringRef> SeenResults;
10302 auto AddCompletion = [&](StringRef
Filename,
bool IsDirectory) {
10305 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
10306 auto R = SeenResults.insert(TypedChunk);
10308 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
10309 *R.first = InternedTyped;
10311 CodeCompleter->getCodeCompletionTUInfo());
10312 Builder.AddTypedTextChunk(InternedTyped);
10320 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
10324 if (!NativeRelDir.empty()) {
10328 auto Begin = llvm::sys::path::begin(NativeRelDir);
10329 auto End = llvm::sys::path::end(NativeRelDir);
10331 llvm::sys::path::append(Dir, *
Begin +
".framework",
"Headers");
10332 llvm::sys::path::append(Dir, ++
Begin, End);
10334 llvm::sys::path::append(Dir, NativeRelDir);
10338 const StringRef &Dirname = llvm::sys::path::filename(Dir);
10339 const bool isQt = Dirname.starts_with(
"Qt") || Dirname ==
"ActiveQt";
10340 const bool ExtensionlessHeaders =
10341 IsSystem || isQt || Dir.ends_with(
".framework/Headers");
10342 std::error_code EC;
10343 unsigned Count = 0;
10344 for (
auto It = FS.dir_begin(Dir, EC);
10345 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
10346 if (++Count == 2500)
10348 StringRef
Filename = llvm::sys::path::filename(It->path());
10353 llvm::sys::fs::file_type
Type = It->type();
10354 if (
Type == llvm::sys::fs::file_type::symlink_file) {
10355 if (
auto FileStatus = FS.status(It->path()))
10356 Type = FileStatus->getType();
10359 case llvm::sys::fs::file_type::directory_file:
10363 NativeRelDir.empty() && !
Filename.consume_back(
".framework"))
10368 case llvm::sys::fs::file_type::regular_file: {
10370 const bool IsHeader =
Filename.ends_with_insensitive(
".h") ||
10371 Filename.ends_with_insensitive(
".hh") ||
10372 Filename.ends_with_insensitive(
".hpp") ||
10373 Filename.ends_with_insensitive(
".hxx") ||
10374 Filename.ends_with_insensitive(
".inc") ||
10375 (ExtensionlessHeaders && !
Filename.contains(
'.'));
10390 switch (IncludeDir.getLookupType()) {
10395 AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
10399 AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
10409 using llvm::make_range;
10413 AddFilesFromIncludeDir(CurFile->getDir().getName(),
false,
10415 for (
const auto &
D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
10416 AddFilesFromDirLookup(
D,
false);
10418 for (
const auto &
D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
10419 AddFilesFromDirLookup(
D,
false);
10420 for (
const auto &
D : make_range(S.system_dir_begin(), S.system_dir_end()))
10421 AddFilesFromDirLookup(
D,
true);
10424 Results.getCompletionContext(), Results.data(),
10435 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10436 CodeCompleter->getCodeCompletionTUInfo(),
10438 Results.EnterNewScope();
10439 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
10443 Twine(Platform) +
"ApplicationExtension")));
10445 Results.ExitScope();
10447 Results.getCompletionContext(), Results.data(),
10454 ResultBuilder Builder(SemaRef, Allocator, CCTUInfo,
10456 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
10457 CodeCompletionDeclConsumer Consumer(
10458 Builder, getASTContext().getTranslationUnitDecl());
10461 !CodeCompleter || CodeCompleter->loadExternal());
10464 if (!CodeCompleter || CodeCompleter->includeMacros())
10466 !CodeCompleter || CodeCompleter->loadExternal(),
true);
10469 Results.insert(Results.end(), Builder.data(),
10470 Builder.data() + Builder.size());
10475 :
SemaBase(S), CodeCompleter(CompletionConsumer) {}
This file provides AST data structures related to concepts.
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
enum clang::sema::@1724::IndirectLocalPathEntry::EntryKind Kind
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines an enumeration for C++ overloaded operators.
Defines the clang::Preprocessor interface.
static std::string getName(const CallEvent &Call)
static AccessResult IsAccessible(Sema &S, const EffectiveContext &EC, AccessTarget &Entity)
Determines whether the accessed entity is accessible.
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...
static void printOverrideString(const CodeCompletionString &CCS, std::string &BeforeName, std::string &NameAndSignature)
static bool isConstructor(const Decl *ND)
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.
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...
static bool isObjCReceiverType(ASTContext &C, QualType T)
static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, bool LoadExternal, bool IncludeUndefined, bool TargetTypeIsPointer=false)
static std::string formatTemplateParameterPlaceholder(const NamedDecl *Param, bool &Optional, const PrintingPolicy &Policy)
static std::string formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlockName=false, bool SuppressBlock=false, std::optional< ArrayRef< QualType > > ObjCSubsts=std::nullopt)
Returns a placeholder string that corresponds to an Objective-C block declaration.
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.
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
static FunctionProtoTypeLoc GetPrototypeLoc(Expr *Fn)
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.
llvm::SmallPtrSet< const IdentifierInfo *, 16 > AddedPropertiesSet
The set of properties that have already been added, referenced by property name.
static bool argMatchesTemplateParams(const ParsedTemplateArgument &Arg, unsigned Index, const TemplateParameterList &Params)
static void setInBaseClass(ResultBuilder::Result &R)
static void AddObjCMethods(ObjCContainerDecl *Container, bool WantInstanceMethods, ObjCMethodKind WantKind, ArrayRef< const 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 bool shouldIgnoreDueToReservedName(const NamedDecl *ND, Sema &SemaRef)
static RecordDecl * getAsRecordDecl(QualType BaseType)
static CodeCompletionString * createTemplateSignatureString(const TemplateDecl *TD, CodeCompletionBuilder &Builder, unsigned CurrentArg, const PrintingPolicy &Policy)
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
static void AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
static const NamedDecl * extractFunctorCallOperator(const NamedDecl *ND)
static void AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
static QualType ProduceSignatureHelp(Sema &SemaRef, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, SourceLocation OpenParLoc, bool Braced)
static std::string FormatFunctionParameter(const PrintingPolicy &Policy, const DeclaratorDecl *Param, bool SuppressName=false, bool SuppressBlock=false, std::optional< ArrayRef< QualType > > ObjCSubsts=std::nullopt)
static void AddOverrideResults(ResultBuilder &Results, const CodeCompletionContext &CCContext, CodeCompletionBuilder &Builder)
static std::string formatObjCParamQualifiers(unsigned ObjCQuals, QualType &Type)
llvm::SmallPtrSet< Selector, 16 > VisitedSelectorSet
A set of selectors, which is used to avoid introducing multiple completions with the same selector in...
static void AddOverloadAggregateChunks(const RecordDecl *RD, const PrintingPolicy &Policy, CodeCompletionBuilder &Result, unsigned CurrentArg)
static void AddTypedefResult(ResultBuilder &Results)
static void AddPrettyFunctionResults(const LangOptions &LangOpts, ResultBuilder &Results)
static QualType getDesignatedType(QualType BaseType, const Designation &Desig)
static void AddObjCPassingTypeChunk(QualType Type, unsigned ObjCDeclQuals, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder)
Add the parenthesized return or parameter type chunk to a code completion string.
static 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 AddObjCStatementResults(ResultBuilder &Results, bool NeedAt)
static bool ObjCPropertyFlagConflicts(unsigned Attributes, unsigned NewFlag)
Determine whether the addition of the given flag to an Objective-C property's attributes will cause a...
static void AddEnumerators(ResultBuilder &Results, ASTContext &Context, EnumDecl *Enum, DeclContext *CurContext, const CoveredEnumerators &Enumerators)
llvm::DenseMap< Selector, llvm::PointerIntPair< ObjCMethodDecl *, 1, bool > > KnownMethodsMap
static const FunctionProtoType * TryDeconstructFunctionLike(QualType T)
Try to find a corresponding FunctionProtoType for function-like types (e.g.
static DeclContext::lookup_result getConstructors(ASTContext &Context, const CXXRecordDecl *Record)
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.
static void AddObjCVisibilityResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
static void addThisCompletion(Sema &S, ResultBuilder &Results)
Add a completion for "this", if we're in a member function.
static void AddObjCImplementationResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
static ObjCMethodDecl * AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword, ArrayRef< const IdentifierInfo * > SelIdents, ResultBuilder &Results)
static void AddRecordMembersCompletionResults(Sema &SemaRef, ResultBuilder &Results, Scope *S, QualType BaseType, ExprValueKind BaseKind, RecordDecl *RD, std::optional< FixItHint > AccessOpFixIt)
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.
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...
static void AddTypeSpecifierResults(const LangOptions &LangOpts, ResultBuilder &Results)
Add type specifiers for the current language as keyword results.
static std::optional< unsigned > getNextAggregateIndexAfterDesignatedInit(const ResultCandidate &Aggregate, ArrayRef< Expr * > Args)
static std::string GetDefaultValueString(const ParmVarDecl *Param, const SourceManager &SM, const LangOptions &LangOpts)
static CodeCompletionContext mapCodeCompletionContext(Sema &S, SemaCodeCompletion::ParserCompletionContext PCC)
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...
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...
static OverloadCompare compareOverloads(const CXXMethodDecl &Candidate, const CXXMethodDecl &Incumbent, const Qualifiers &ObjectQuals, ExprValueKind ObjectKind, const ASTContext &Ctx)
static void FindImplementableMethods(ASTContext &Context, ObjCContainerDecl *Container, std::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,...
static bool anyNullArguments(ArrayRef< Expr * > Args)
static const char * noUnderscoreAttrScope(llvm::StringRef Scope)
static void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function)
static void MaybeAddSentinel(Preprocessor &PP, const NamedDecl *FunctionOrMethod, CodeCompletionBuilder &Result)
static void AddOverloadParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const FunctionDecl *Function, const FunctionProtoType *Prototype, FunctionProtoTypeLoc PrototypeLoc, CodeCompletionBuilder &Result, unsigned CurrentArg, unsigned Start=0, bool InOptional=false)
Add function overload parameter chunks to the given code completion string.
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)
static void HandleCodeCompleteResults(Sema *S, CodeCompleteConsumer *CodeCompleter, const CodeCompletionContext &Context, CodeCompletionResult *Results, unsigned NumResults)
static void AddTypeQualifierResults(DeclSpec &DS, ResultBuilder &Results, const LangOptions &LangOpts)
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...
static ObjCContainerDecl * getContainerDef(ObjCContainerDecl *Container)
Retrieve the container definition, if any?
static const char * underscoreAttrScope(llvm::StringRef Scope)
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method, ObjCMethodKind WantKind, ArrayRef< const IdentifierInfo * > SelIdents, bool AllowSameLength=true)
static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt)
static bool WantTypesInContext(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts)
CodeCompleteConsumer::OverloadCandidate ResultCandidate
static std::string templateResultType(const TemplateDecl *TD, const PrintingPolicy &Policy)
static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, CodeCompletionBuilder &Result)
Add the name of the given declaration.
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper, ResultBuilder &Results)
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...
static bool InheritsFromClassNamed(ObjCInterfaceDecl *Class, StringRef Name)
Determine whether the given class is or inherits from a class by the given name.
#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword)
Macro that optionally prepends an "@" to the string literal passed in via Keyword,...
static bool isAcceptableObjCSelector(Selector Sel, ObjCMethodKind WantKind, ArrayRef< const IdentifierInfo * > SelIdents, bool AllowSameLength=true)
static QualType getPreferredTypeOfBinaryRHS(Sema &S, Expr *LHS, tok::TokenKind Op)
static void AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC, Scope *S, Sema &SemaRef, ResultBuilder &Results)
Add language constructs that show up for "ordinary" names.
static QualType getPreferredTypeOfUnaryArg(Sema &S, QualType ContextType, tok::TokenKind Op)
Get preferred type for an argument of an unary expression.
static void AddUsingAliasResult(CodeCompletionBuilder &Builder, ResultBuilder &Results)
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...
ObjCMethodKind
Describes the kind of Objective-C method that we want to find via code completion.
@ MK_OneArgSelector
One-argument selector.
@ MK_ZeroArgSelector
Zero-argument (unary) selector.
@ MK_Any
Any kind of method, provided it means other specified criteria.
static void mergeCandidatesWithResults(Sema &SemaRef, SmallVectorImpl< ResultCandidate > &Results, OverloadCandidateSet &CandidateSet, SourceLocation Loc, size_t ArgSize)
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.
static void AddStaticAssertResult(CodeCompletionBuilder &Builder, ResultBuilder &Results, const LangOptions &LangOpts)
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
static bool isNamespaceScope(Scope *S)
Determine whether this scope denotes a namespace.
static PrintingPolicy getCompletionPrintingPolicy(const ASTContext &Context, const Preprocessor &PP)
This file declares facilities that support code completion.
This file declares semantic analysis for Objective-C.
static TemplateDecl * getDescribedTemplate(Decl *Templated)
Defines various enumerations that describe declaration and type specifiers.
enum clang::format::@1335::AnnotatingParser::Context::@353 ContextType
C Language Family Type Representation.
pointer(const DeclIndexPair &Value)
const DeclIndexPair * operator->() const
pointer operator->() const
reference operator*() const
std::ptrdiff_t difference_type
friend bool operator!=(const iterator &X, const iterator &Y)
iterator(const NamedDecl *SingleDecl, unsigned Index)
std::input_iterator_tag iterator_category
iterator(const DeclIndexPair *Iterator)
friend bool operator==(const iterator &X, const iterator &Y)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
DeclarationNameTable DeclarationNames
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
SelectorTable & Selectors
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getElementType() const
Syntax
The style used to specify an attribute.
Type source information for an attributed type.
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Wrapper for source info for block pointers.
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Represents a static or instance method of a struct/union/class.
overridden_method_range overridden_methods() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Qualifiers getMethodQualifiers() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
CXXRecordDecl * getDefinition() const
base_class_range vbases()
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CaseStmt - Represent a case statement.
Represents a character-granular source range.
static CharSourceRange getTokenRange(SourceRange R)
Declaration of a class template.
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments, bool Braced) const
Create a new code-completion string that describes the function signature of this overload candidate.
const FunctionType * getFunctionType() const
Retrieve the function type of the entity, regardless of how the function is stored.
const TemplateDecl * getTemplate() const
CandidateKind getKind() const
Determine the kind of overload candidate.
const RecordDecl * getAggregate() const
Retrieve the aggregate type being initialized.
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
const FunctionProtoTypeLoc getFunctionProtoTypeLoc() const
Retrieve the function ProtoTypeLoc candidate.
@ CK_Aggregate
The candidate is aggregate initialization of a record type.
@ CK_Template
The candidate is a template, template arguments are being completed.
unsigned getNumParams() const
Get the number of parameters in this signature.
Abstract interface for a consumer of code-completion information.
bool includeGlobals() const
Whether to include global (top-level) declaration results.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results.
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced)
An allocator used specifically for the purpose of code completion.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
A builder class used to construct new code-completion strings.
CodeCompletionString * TakeString()
Take the resulting completion string.
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
void AddTextChunk(const char *Text)
Add a new text chunk.
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
The context in which code completion occurred, so that the code-completion consumer can process the r...
Kind getKind() const
Retrieve the kind of code-completion context.
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
@ CCC_TypeQualifiers
Code completion within a type-qualifier list.
@ CCC_ObjCMessageReceiver
Code completion occurred where an Objective-C message receiver is expected.
@ CCC_PreprocessorExpression
Code completion occurred within a preprocessor expression.
@ CCC_ObjCCategoryName
Code completion where an Objective-C category name is expected.
@ CCC_ObjCIvarList
Code completion occurred within the instance variable list of an Objective-C interface,...
@ CCC_Statement
Code completion occurred where a statement (or declaration) is expected in a function,...
@ CCC_Type
Code completion occurred where a type name is expected.
@ CCC_ArrowMemberAccess
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
@ CCC_ClassStructUnion
Code completion occurred within a class, struct, or union.
@ CCC_ObjCInterface
Code completion occurred within an Objective-C interface, protocol, or category interface.
@ CCC_ObjCPropertyAccess
Code completion occurred on the right-hand side of an Objective-C property access expression.
@ CCC_Expression
Code completion occurred where an expression is expected.
@ CCC_SelectorName
Code completion for a selector, as in an @selector expression.
@ CCC_TopLevelOrExpression
Code completion at a top level, i.e.
@ CCC_EnumTag
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
@ CCC_UnionTag
Code completion occurred after the "union" keyword, to indicate a union name.
@ CCC_ParenthesizedExpression
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
@ CCC_TopLevel
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope.
@ CCC_ClassOrStructTag
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name.
@ CCC_ObjCClassMessage
Code completion where an Objective-C class message is expected.
@ CCC_ObjCImplementation
Code completion occurred within an Objective-C implementation or category implementation.
@ CCC_IncludedFile
Code completion inside the filename part of a #include directive.
@ CCC_ObjCInstanceMessage
Code completion where an Objective-C instance message is expected.
@ CCC_SymbolOrNewName
Code completion occurred where both a new name and an existing symbol is permissible.
@ CCC_Recovery
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
@ CCC_ObjCProtocolName
Code completion occurred where a protocol name is expected.
@ CCC_NewName
Code completion occurred where a new name is expected.
@ CCC_MacroNameUse
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
@ CCC_Symbol
Code completion occurred where an existing name(such as type, function or variable) is expected.
@ CCC_Attribute
Code completion of an attribute name.
@ CCC_Other
An unspecified code-completion context.
@ CCC_DotMemberAccess
Code completion occurred on the right-hand side of a member access expression using the dot operator.
@ CCC_MacroName
Code completion occurred where an macro is being defined.
@ CCC_Namespace
Code completion occurred where a namespace or namespace alias is expected.
@ CCC_PreprocessorDirective
Code completion occurred where a preprocessor directive is expected.
@ CCC_NaturalLanguage
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
@ CCC_ObjCInterfaceName
Code completion where the name of an Objective-C class is expected.
@ CCC_ObjCClassForwardDecl
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
void setPreferredType(QualType T)
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
void setIsUsingDeclaration(bool V)
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
Captures a result of code completion.
bool DeclaringEntity
Whether we're completing a declaration of the given entity, rather than a use of that entity.
ResultKind Kind
The kind of result stored here.
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling.
CXAvailabilityKind Availability
The availability of this result.
NestedNameSpecifier * Qualifier
If the result should have a nested-name-specifier, this is it.
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program.
bool QualifierIsInformative
Whether this result was found via lookup into a base class.
const NamedDecl * Declaration
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to.
CodeCompletionString * createCodeCompletionStringForDecl(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
CodeCompletionString * CreateCodeCompletionStringForMacro(Preprocessor &PP, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Creates a new code-completion string for the macro result.
unsigned StartParameter
Specifies which parameter (of a function, Objective-C method, macro, etc.) we should start with when ...
bool InBaseClass
Whether this is a class member from base class.
unsigned Priority
The priority of this particular code-completion result.
bool StartsNestedNameSpecifier
Whether this declaration is the beginning of a nested-name-specifier and, therefore,...
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert.
bool FunctionCanBeCall
When completing a function, whether it can be a call.
bool AllParametersAreInformative
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative".
CodeCompletionString * createCodeCompletionStringForOverride(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
const IdentifierInfo * Macro
When Kind == RK_Macro, the identifier that refers to a macro.
@ RK_Pattern
Refers to a precomputed pattern.
@ RK_Declaration
Refers to a declaration.
@ RK_Macro
Refers to a macro.
@ RK_Keyword
Refers to a keyword or symbol.
A "string" used to describe how code completion can be performed for an entity.
@ CK_Optional
A code completion string that is entirely optional.
@ CK_CurrentParameter
A piece of text that describes the parameter that corresponds to the code-completion location within ...
@ CK_Comma
A comma separator (',').
@ CK_Placeholder
A string that acts as a placeholder for, e.g., a function call argument.
@ CK_LeftParen
A left parenthesis ('(').
@ CK_HorizontalSpace
Horizontal whitespace (' ').
@ CK_RightAngle
A right angle bracket ('>').
@ CK_LeftBracket
A left bracket ('[').
@ CK_RightParen
A right parenthesis (')').
@ CK_RightBrace
A right brace ('}').
@ CK_VerticalSpace
Vertical whitespace ('\n' or '\r\n', depending on the platform).
@ CK_SemiColon
A semicolon (';').
@ CK_TypedText
The piece of text that the user is expected to type to match the code-completion string,...
@ CK_RightBracket
A right bracket (']').
@ CK_LeftBrace
A left brace ('{').
@ CK_LeftAngle
A left angle bracket ('<').
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
const TypeClass * getTypePtr() const
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isRequiresExprBody() const
bool isFileContext() const
bool isObjCContainer() const
ASTContext & getParentASTContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
decl_iterator decls_end() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
decl_iterator decls_begin() const
Captures information about "declaration specifiers".
static const TST TST_typename
TST getTypeSpecType() const
static const TST TST_interface
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static const TST TST_union
TSC getTypeSpecComplex() const
ParsedType getRepAsType() const
static const TST TST_enum
static const TST TST_class
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
bool isTypeAltiVecVector() const
TypeSpecifierSign getTypeSpecSign() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
@ FOK_Undeclared
A friend of a previously-undeclared entity.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
unsigned getIdentifierNamespace() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
@ IDNS_Member
Members, declared with object declarations within tag definitions.
@ IDNS_ObjCProtocol
Objective C @protocol.
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
@ IDNS_LocalExtern
This declaration is a function-local extern declaration of a variable or function.
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
TranslationUnitDecl * getTranslationUnitDecl()
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
uintptr_t getAsOpaqueInteger() const
Get the representation of this declaration name as an opaque integer.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Represents a ValueDecl that came out of a declarator.
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
Represents a qualified type name for which the type name is dependent.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
const IdentifierInfo * getIdentifier() const
Retrieve the identifier that terminates this type name.
A qualified reference to a name whose declaration cannot yet be resolved.
Designation - Represent a full designation, which is a sequence of designators.
const Designator & getDesignator(unsigned Idx) const
unsigned getNumDesignators() const
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
Recursive AST visitor that supports extension via dynamic dispatch.
virtual bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Recursively visit a C++ nested-name-specifier with location information.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
virtual Selector GetExternalSelector(uint32_t ID)
Resolve a selector ID into a selector.
virtual uint32_t GetNumExternalSelectors()
Returns the number of selectors known to the external AST source.
Represents a member of a struct/union/class.
llvm::vfs::FileSystem & getVirtualFileSystem() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
Represents a function declaration or definition.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
param_iterator param_end()
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
size_t param_size() const
Represents a prototype with parameter type info, e.g.
bool isVariadic() const
Whether this function prototype is variadic.
Declaration of a template function.
Wrapper for source info for functions.
unsigned getNumParams() const
ParmVarDecl * getParam(unsigned i) const
TypeLoc getReturnLoc() const
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef deuglifiedName() const
If the identifier is an "uglified" reserved name, return a cleaned form.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const TypeClass * getTypePtr() const
The injected class name of a C++ class template or class template partial specialization.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Represents the results of name lookup.
const UnresolvedSetImpl & asUnresolvedSet() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
Encapsulates the data about a macro definition (e.g.
bool isC99Varargs() const
bool isFunctionLike() const
param_iterator param_begin() const
IdentifierInfo *const * param_iterator
Parameters - The list of parameters for a function-like macro.
param_iterator param_end() const
bool isUsedForHeaderGuard() const
Determine whether this macro was used for a header guard.
virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, Module::NameVisibilityKind Visibility, bool IsInclusionDirective)=0
Attempt to load the given module.
Describes a module or submodule.
@ AllVisible
All of the names in this module are visible.
ModuleKind Kind
The kind of this module.
llvm::iterator_range< submodule_iterator > submodules()
@ ImplicitGlobalModuleFragment
This is an implicit fragment of the global module which contains only language linkage declarations (...
@ ModulePartitionInterface
This is a C++20 module partition interface.
@ ModuleInterfaceUnit
This is a C++20 module interface unit.
@ PrivateModuleFragment
This is the private module fragment within some C++ module.
@ ExplicitGlobalModuleFragment
This is the explicit Global Module Fragment of a modular TU.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
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...
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine if the declaration obeys the reserved identifier rules of the given language.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
ObjCCategoryDecl - Represents a category declaration.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCContainerDecl - Represents a container for method declarations.
Captures information about "declaration specifiers" specific to Objective-C.
ObjCPropertyAttribute::Kind getPropertyAttributes() const
ObjCDeclQualifier getObjCDeclQualifier() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
bool hasDefinition() const
Determine whether this class has been defined.
protocol_range protocols() const
known_categories_range known_categories() const
ObjCImplementationDecl * getImplementation() const
visible_categories_range visible_categories() const
ObjCInterfaceDecl * getSuperClass() const
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCList - This is a simple template class used to hold various lists of decls etc,...
@ SuperInstance
The receiver is the instance of the superclass object.
@ Instance
The receiver is an object instance.
@ SuperClass
The receiver is a superclass.
@ Class
The receiver is a class.
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCDeclQualifier getObjCDeclQualifier() const
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
param_const_iterator param_end() const
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
param_const_iterator param_begin() const
const ParmVarDecl *const * param_const_iterator
Selector getSelector() const
bool isInstanceMethod() const
QualType getReturnType() const
ParmVarDecl *const * param_iterator
ObjCInterfaceDecl * getClassInterface()
Represents a pointer to an Objective C object.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
Represents a class type in Objective C.
Represents one property declaration in an Objective-C interface.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
Selector getGetterName() const
Represents an Objective-C protocol declaration.
void * getAsOpaquePtr() const
static OpaquePtr make(QualType P)
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
CandidateSetKind getKind() const
Represents a parameter to a function.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
Represents the parsed form of a C++ template argument.
KindType getKind() const
Determine what kind of template argument we have.
@ Type
A template type parameter, stored as a type.
@ Template
A template template argument, stored as a template name.
@ NonType
A non-type template parameter, stored as an expression.
Wrapper for source info for pointers.
PointerType - C99 6.7.5.1 - Pointer Declarators.
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...
void enterCondition(Sema &S, SourceLocation Tok)
void enterTypeCast(SourceLocation Tok, QualType CastType)
Handles all type casts, including C-style cast, C++ casts, etc.
void enterMemAccess(Sema &S, SourceLocation Tok, Expr *Base)
void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS)
void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind, SourceLocation OpLoc)
void enterReturn(Sema &S, SourceLocation Tok)
void enterDesignatedInitializer(SourceLocation Tok, QualType BaseType, const Designation &D)
Handles e.g. BaseType{ .D = Tok...
void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op)
void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc)
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
OptionalFileEntryRef getFileEntry() const
getFileEntry - Return the FileEntry corresponding to this FileID.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with this preprocessor.
macro_iterator macro_end(bool IncludeExternalMacros=true) const
SourceManager & getSourceManager() const
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
bool isMacroDefined(StringRef Id)
MacroMap::const_iterator macro_iterator
llvm::iterator_range< macro_iterator > macros(bool IncludeExternalMacros=true) const
PreprocessorLexer * getCurrentFileLexer() const
Return the current file lexer being lexed from.
HeaderSearch & getHeaderSearchInfo() const
const LangOptions & getLangOpts() const
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Wrapper of type source information for a type with non-trivial direct qualifiers.
The collection of all-type qualifiers we support.
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
@ ClassScope
The scope of a struct/union/class definition.
@ DeclScope
This is a scope that can contain a declaration.
This table allows us to fully hide how we implement multi-keyword caching.
Selector getNullarySelector(const IdentifierInfo *ID)
Selector getSelector(unsigned NumArgs, const IdentifierInfo **IIV)
Can create any sort of selector.
Selector getUnarySelector(const IdentifierInfo *ID)
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
bool isUnarySelector() const
bool isNull() const
Determine whether this is the empty selector.
unsigned getNumArgs() const
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
void CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion=AttributeCompletion::Attribute, const IdentifierInfo *Scope=nullptr)
QualType ProduceTemplateArgumentSignatureHelp(TemplateTy, ArrayRef< ParsedTemplateArgument >, SourceLocation LAngleLoc)
QualType ProduceCtorInitMemberSignatureHelp(Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy, ArrayRef< Expr * > ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc, bool Braced)
void CodeCompleteObjCClassForwardDecl(Scope *S)
void CodeCompleteNamespaceAliasDecl(Scope *S)
void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
void CodeCompleteObjCAtStatement(Scope *S)
void CodeCompleteUsing(Scope *S)
void CodeCompleteObjCMessageReceiver(Scope *S)
void CodeCompleteOperatorName(Scope *S)
void CodeCompleteUsingDirective(Scope *S)
void CodeCompleteObjCProtocolDecl(Scope *S)
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
ParserCompletionContext
Describes the context in which code completion occurs.
@ PCC_LocalDeclarationSpecifiers
Code completion occurs within a sequence of declaration specifiers within a function,...
@ PCC_MemberTemplate
Code completion occurs following one or more template headers within a class.
@ PCC_Condition
Code completion occurs within the condition of an if, while, switch, or for statement.
@ PCC_ParenthesizedExpression
Code completion occurs in a parenthesized expression, which might also be a type cast.
@ PCC_TopLevelOrExpression
Code completion occurs at top-level in a REPL session.
@ PCC_Class
Code completion occurs within a class, struct, or union.
@ PCC_ForInit
Code completion occurs at the beginning of the initialization statement (or expression) in a for loop...
@ PCC_Type
Code completion occurs where only a type is permitted.
@ PCC_ObjCImplementation
Code completion occurs within an Objective-C implementation or category implementation.
@ PCC_ObjCInterface
Code completion occurs within an Objective-C interface, protocol, or category.
@ PCC_Namespace
Code completion occurs at top-level or namespace context.
@ PCC_Expression
Code completion occurs within an expression.
@ PCC_RecoveryInFunction
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
@ PCC_ObjCInstanceVariableList
Code completion occurs within the list of instance variables in an Objective-C interface,...
@ PCC_Template
Code completion occurs following one or more template headers.
@ PCC_Statement
Code completion occurs within a statement, which may also be an expression or a declaration.
void CodeCompleteObjCAtDirective(Scope *S)
void CodeCompleteObjCPropertySetter(Scope *S)
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
void CodeCompleteCase(Scope *S)
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCInterfaceDecl(Scope *S)
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
void CodeCompletePreprocessorMacroName(bool IsDefinition)
void CodeCompleteInPreprocessorConditionalExclusion(Scope *S)
void CodeCompleteObjCAtExpression(Scope *S)
void CodeCompletePreprocessorExpression()
void CodeCompleteTypeQualifiers(DeclSpec &DS)
void CodeCompleteObjCPropertyDefinition(Scope *S)
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression)
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
void CodeCompleteAfterFunctionEquals(Declarator &D)
QualType ProduceConstructorSignatureHelp(QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args, SourceLocation OpenParLoc, bool Braced)
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for.
QualType ProduceCallSignatureHelp(Expr *Fn, ArrayRef< Expr * > Args, SourceLocation OpenParLoc)
Determines the preferred type of the current function argument, by examining the signatures of all po...
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< const IdentifierInfo * > SelIdents)
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, bool IsUsingDeclaration, QualType BaseType, QualType PreferredType)
void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled)
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCSelector(Scope *S, ArrayRef< const IdentifierInfo * > SelIdents)
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
void CodeCompleteObjCImplementationDecl(Scope *S)
void CodeCompleteAfterIf(Scope *S, bool IsBracedThen)
void CodeCompleteObjCMethodDecl(Scope *S, std::optional< bool > IsInstanceMethod, ParsedType ReturnType)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
void CodeCompleteNaturalLanguage()
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, const IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
void CodeCompleteInitializer(Scope *S, Decl *D)
void CodeCompleteNamespaceDecl(Scope *S)
void CodeCompleteDesignator(const QualType BaseType, llvm::ArrayRef< Expr * > InitExprs, const Designation &D)
Trigger code completion for a record of BaseType.
void CodeCompletePreprocessorDirective(bool InConditional)
SemaCodeCompletion(Sema &S, CodeCompleteConsumer *CompletionConsumer)
void CodeCompleteBracketDeclarator(Scope *S)
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCAtVisibility(Scope *S)
void CodeCompleteTag(Scope *S, unsigned TagSpec)
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar)
void CodeCompleteAvailabilityPlatformName()
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement, QualType PreferredType)
void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, bool IsParameter)
void CodeCompleteObjCPropertyGetter(Scope *S)
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS, QualType PreferredType)
ObjCInterfaceDecl * getObjCInterfaceDecl(const IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Find the protocol with the given name, if any.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
Sema - This implements semantic analysis and AST building for C.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
@ LookupAnyName
Look up any declaration with any name.
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
Preprocessor & getPreprocessor() const
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
IdentifierInfo * getSuperIdentifier() const
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
ValueDecl * tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl, CXXScopeSpec &SS, ParsedType TemplateTypeTy, IdentifierInfo *MemberOrBase)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
const LangOptions & getLangOpts() const
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
SemaCodeCompletion & CodeCompletion()
sema::FunctionScopeInfo * getCurFunction() const
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
SourceManager & getSourceManager() const
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
ExternalSemaSource * getExternalSource() const
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false, bool FirstArgumentIsBase=false)
Add all of the function declarations in the given function set to the overload candidate set.
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...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceManager & SourceMgr
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
Encodes a location in the source.
This class handles loading and caching of source files into memory.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
FileManager & getFileManager() const
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
SwitchStmt - This represents a 'switch' stmt.
Represents the declaration of a struct/union/class/enum.
A convenient class for passing around template argument information.
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
@ Type
The template argument is a type.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
bool hasParameterPack() const
Determine whether this template parameter list contains a parameter pack.
ArrayRef< NamedDecl * > asArray()
Represents a type template specialization; the template must be a class template, a type alias templa...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
TemplateTypeParmDecl * getDecl() const
The top declaration context.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Represents a declaration of a type.
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
QualType getType() const
Get the type for which this source info wrapper provides information.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isBooleanType() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
bool isPointerType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isObjCObjectOrInterfaceType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isTemplateTypeParmType() const
bool isMemberPointerType() const
bool isObjCIdType() const
bool isObjCObjectType() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCObjectPointerType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
std::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...
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Wrapper for source info for typedefs.
Represents a C++ unqualified-id that has been parsed.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
void append(iterator I, iterator E)
A set of unresolved declarations.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a C++11 virt-specifier-seq.
bool isOverrideSpecified() const
bool isFinalSpecified() const
Consumes visible declarations found when searching for all visible names within a given scope or cont...
A static requirement that can be used in a requires-expression to check properties of types and expre...
Retains information about a block that is currently being parsed.
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
SmallVector< SwitchInfo, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
CXCursorKind
Describes the kind of entity that a cursor refers to.
@ CXCursor_ObjCInterfaceDecl
An Objective-C @interface.
@ CXCursor_Namespace
A C++ namespace.
@ CXCursor_TypedefDecl
A typedef.
@ CXCursor_CXXAccessSpecifier
An access specifier.
@ CXCursor_EnumConstantDecl
An enumerator constant.
@ CXCursor_ConversionFunction
A C++ conversion function.
@ CXCursor_ConceptDecl
a concept declaration.
@ CXCursor_ClassTemplate
A C++ class template.
@ CXCursor_UnionDecl
A C or C++ union.
@ CXCursor_ObjCSynthesizeDecl
An Objective-C @synthesize definition.
@ CXCursor_ParmDecl
A function or method parameter.
@ CXCursor_FieldDecl
A field (in C) or non-static data member (in C++) in a struct, union, or C++ class.
@ CXCursor_CXXMethod
A C++ class method.
@ CXCursor_EnumDecl
An enumeration.
@ CXCursor_ObjCClassMethodDecl
An Objective-C class method.
@ CXCursor_TranslationUnit
Cursor that represents the translation unit itself.
@ CXCursor_ClassTemplatePartialSpecialization
A C++ class template partial specialization.
@ CXCursor_ObjCProtocolDecl
An Objective-C @protocol declaration.
@ CXCursor_FunctionTemplate
A C++ function template.
@ CXCursor_ObjCImplementationDecl
An Objective-C @implementation.
@ CXCursor_NonTypeTemplateParameter
A C++ non-type template parameter.
@ CXCursor_FunctionDecl
A function.
@ CXCursor_ObjCPropertyDecl
An Objective-C @property declaration.
@ CXCursor_Destructor
A C++ destructor.
@ CXCursor_ObjCIvarDecl
An Objective-C instance variable.
@ CXCursor_TypeAliasTemplateDecl
@ CXCursor_ObjCCategoryImplDecl
An Objective-C @implementation for a category.
@ CXCursor_ObjCDynamicDecl
An Objective-C @dynamic definition.
@ CXCursor_MacroDefinition
@ CXCursor_VarDecl
A variable.
@ CXCursor_TemplateTypeParameter
A C++ template type parameter.
@ CXCursor_TemplateTemplateParameter
A C++ template template parameter.
@ CXCursor_UnexposedDecl
A declaration whose specific kind is not exposed via this interface.
@ CXCursor_ObjCInstanceMethodDecl
An Objective-C instance method.
@ CXCursor_StructDecl
A C or C++ struct.
@ CXCursor_UsingDeclaration
A C++ using declaration.
@ CXCursor_LinkageSpec
A linkage specification, e.g.
@ CXCursor_ClassDecl
A C++ class.
@ CXCursor_ObjCCategoryDecl
An Objective-C @interface for a category.
@ CXCursor_StaticAssert
A static_assert or _Static_assert node.
@ CXCursor_ModuleImportDecl
A module import declaration.
@ CXCursor_MemberRef
A reference to a member of a struct, union, or class that occurs in some non-expression context,...
@ CXCursor_NamespaceAlias
A C++ namespace alias declaration.
@ CXCursor_Constructor
A C++ constructor.
@ CXCursor_FriendDecl
a friend declaration.
@ CXCursor_TypeAliasDecl
A C++ alias declaration.
@ CXCursor_UsingDirective
A C++ using directive.
@ CXAvailability_Available
The entity is available.
@ CXAvailability_Deprecated
The entity is available, but has been deprecated (and its use is not recommended).
@ CXAvailability_NotAvailable
The entity is not available; any use of it will be an error.
@ kind_nullability
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
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...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool Alloc(InterpState &S, CodePtr OpPC, const Descriptor *Desc)
bool Add(InterpState &S, CodePtr OpPC)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
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.
bool isReservedInAllContexts(ReservedIdentifierStatus Status)
Determine whether an identifier is reserved in all contexts.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
const RawComment * getParameterComment(const ASTContext &Ctx, const CodeCompleteConsumer::OverloadCandidate &Result, unsigned ArgIndex)
Get the documentation comment used to produce CodeCompletionString::BriefComment for OverloadCandidat...
@ LCK_This
Capturing the *this object by reference.
@ IK_ConstructorName
A constructor name.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ Property
The type of a property.
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion.
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern.
@ CCF_ExactTypeMatch
Divide by this factor when a code-completion result's type exactly matches the type we expect.
@ CCF_SimilarTypeMatch
Divide by this factor when a code-completion result's type is similar to the type we expect (e....
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
const RawComment * getCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Declaration.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
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...
@ CCP_Type
Priority for a type.
@ CCP_ObjC_cmd
Priority for the Objective-C "_cmd" implicit parameter.
@ CCP_Keyword
Priority for a language keyword (that isn't any of the other categories).
@ CCP_Macro
Priority for a preprocessor macro.
@ CCP_LocalDeclaration
Priority for a declaration that is in the local scope.
@ CCP_Unlikely
Priority for a result that isn't likely to be what the user wants, but is included for completeness.
@ CCP_NestedNameSpecifier
Priority for a nested-name-specifier.
@ CCP_SuperCompletion
Priority for a send-to-super completion.
@ CCP_NextInitializer
Priority for the next initialization in a constructor initializer list.
@ CCP_Declaration
Priority for a non-type declaration.
@ CCP_Constant
Priority for a constant value (e.g., enumerator).
@ CCP_MemberDeclaration
Priority for a member declaration found from the current method or member function.
@ CCP_EnumInCase
Priority for an enumeration constant inside a switch whose condition is of the enumeration type.
@ CCP_CodePattern
Priority for a code pattern.
const FunctionProtoType * T
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name.
bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function)
llvm::StringRef getAsString(SyncScope S)
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ CCD_SelectorMatch
The selector of the given message exactly matches the selector of the current method,...
@ CCD_ObjectQualifierMatch
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
@ CCD_bool_in_ObjC
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
@ CCD_InBaseClass
The result is in a base class.
@ CCD_ProbablyNotObjCCollection
Adjustment for KVC code pattern priorities when it doesn't look like the.
@ CCD_BlockPropertySetter
An Objective-C block property completed as a setter with a block placeholder.
@ CCD_MethodAsProperty
An Objective-C method being used as a property.
@ StartsWithDoubleUnderscore
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
bool IntegralConstantExpression
SmallVector< Decl *, 4 > IgnoreDecls
CodeCompleteExpressionData(QualType PreferredType=QualType(), bool IsParenthesized=false)
Represents a complete lambda introducer.
SmallVector< LambdaCapture, 4 > Captures
LambdaCaptureDefault Default
a linked list of methods with the same selector name but different signatures.
ObjCMethodDecl * getMethod() const
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
static ArrayRef< const ParsedAttrInfo * > getAllBuiltin()
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressUnwrittenScope
Suppress printing parts of scope specifiers that are never written, e.g., for anonymous namespaces.
unsigned AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g.,...
unsigned CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
unsigned SuppressScope
Suppresses printing of scope specifiers.
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.