47#include "llvm/ADT/ArrayRef.h"
48#include "llvm/ADT/DenseSet.h"
49#include "llvm/ADT/SmallBitVector.h"
50#include "llvm/ADT/SmallPtrSet.h"
51#include "llvm/ADT/SmallString.h"
52#include "llvm/ADT/StringExtras.h"
53#include "llvm/ADT/StringSwitch.h"
54#include "llvm/ADT/Twine.h"
55#include "llvm/ADT/iterator_range.h"
56#include "llvm/Support/Casting.h"
57#include "llvm/Support/Path.h"
58#include "llvm/Support/raw_ostream.h"
77 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
83 std::vector<Result> Results;
90 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
95 class ShadowMapEntry {
100 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector *> DeclOrVector;
104 unsigned SingleDeclIndex = 0;
107 ShadowMapEntry() =
default;
108 ShadowMapEntry(
const ShadowMapEntry &) =
delete;
109 ShadowMapEntry(ShadowMapEntry &&Move) { *
this = std::move(Move); }
110 ShadowMapEntry &operator=(
const ShadowMapEntry &) =
delete;
111 ShadowMapEntry &operator=(ShadowMapEntry &&Move) {
112 SingleDeclIndex =
Move.SingleDeclIndex;
113 DeclOrVector =
Move.DeclOrVector;
114 Move.DeclOrVector =
nullptr;
119 if (DeclOrVector.isNull()) {
122 SingleDeclIndex = Index;
127 DeclOrVector.dyn_cast<
const NamedDecl *>()) {
130 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
131 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
136 DeclOrVector.get<DeclIndexPairVector *>()->push_back(
137 DeclIndexPair(ND, Index));
141 if (DeclIndexPairVector *Vec =
142 DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
150 iterator begin()
const;
151 iterator end()
const;
157 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
174 bool AllowNestedNameSpecifiers;
185 std::list<ShadowMap> ShadowMaps;
199 bool HasObjectTypeQualifiers;
211 void AdjustResultPriorityForDecl(Result &R);
213 void MaybeAddConstructorResults(Result R);
219 LookupFilter Filter =
nullptr)
220 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
222 HasObjectTypeQualifiers(
false), CompletionContext(CompletionContext),
223 ObjCImplementation(nullptr) {
226 switch (CompletionContext.
getKind()) {
234 if (Method->isInstanceMethod())
236 ObjCImplementation =
Interface->getImplementation();
245 unsigned getBasePriority(
const NamedDecl *D);
249 bool includeCodePatterns()
const {
255 void setFilter(LookupFilter Filter) { this->Filter =
Filter; }
257 Result *data() {
return Results.empty() ? nullptr : &Results.front(); }
258 unsigned size()
const {
return Results.size(); }
259 bool empty()
const {
return Results.empty(); }
274 ObjectTypeQualifiers = Quals;
276 HasObjectTypeQualifiers =
true;
284 void setPreferredSelector(
Selector Sel) { PreferredSelector = Sel; }
289 return CompletionContext;
293 void allowNestedNameSpecifiers(
bool Allow =
true) {
294 AllowNestedNameSpecifiers = Allow;
299 Sema &getSema()
const {
return SemaRef; }
313 bool isInterestingDecl(
const NamedDecl *ND,
314 bool &AsNestedNameSpecifier)
const;
339 bool CheckHiddenResult(Result &R,
DeclContext *CurContext,
349 void MaybeAddResult(Result R,
DeclContext *CurContext =
nullptr);
366 bool InBaseClass,
QualType BaseExprType);
369 void AddResult(Result R);
372 void EnterNewScope();
391 bool IsOrdinaryName(
const NamedDecl *ND)
const;
392 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
393 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
394 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
395 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
397 bool IsClassOrStruct(
const NamedDecl *ND)
const;
399 bool IsNamespace(
const NamedDecl *ND)
const;
400 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
402 bool IsMember(
const NamedDecl *ND)
const;
403 bool IsObjCIvar(
const NamedDecl *ND)
const;
404 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
405 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
406 bool IsObjCCollection(
const NamedDecl *ND)
const;
407 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
417 ComputeType =
nullptr;
418 Type = BSI->ReturnType;
422 ComputeType =
nullptr;
425 }
else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(S.
CurContext)) {
426 ComputeType =
nullptr;
427 Type = Method->getReturnType();
435 auto *VD = llvm::dyn_cast_or_null<ValueDecl>(D);
436 ComputeType =
nullptr;
448 ComputeType =
nullptr;
457 this->ComputeType = ComputeType;
467 if (ExpectedLoc == LParLoc)
478 if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
481 if (Op == tok::minus)
494 case tok::minusequal:
496 case tok::percentequal:
498 case tok::slashequal:
504 case tok::equalequal:
505 case tok::exclaimequal:
509 case tok::greaterequal:
513 case tok::greatergreater:
514 case tok::greatergreaterequal:
516 case tok::lesslessequal:
523 case tok::caretcaret:
530 case tok::caretequal:
538 case tok::periodstar:
566 case tok::minusminus:
576 assert(
false &&
"unhandled unary op");
585 ComputeType =
nullptr;
592 if (!Enabled || !
Base)
595 if (ExpectedLoc !=
Base->getBeginLoc())
606 ComputeType =
nullptr;
615 ComputeType =
nullptr;
624 ComputeType =
nullptr;
632 ComputeType =
nullptr;
638 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
639 unsigned SingleDeclIndex;
659 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) {}
662 : DeclOrIterator(Iterator), SingleDeclIndex(0) {}
665 if (DeclOrIterator.is<
const NamedDecl *>()) {
671 const DeclIndexPair *I = DeclOrIterator.get<
const DeclIndexPair *>();
687 return *DeclOrIterator.get<
const DeclIndexPair *>();
693 return X.DeclOrIterator.getOpaqueValue() ==
694 Y.DeclOrIterator.getOpaqueValue() &&
695 X.SingleDeclIndex == Y.SingleDeclIndex;
704ResultBuilder::ShadowMapEntry::begin()
const {
705 if (DeclOrVector.isNull())
709 return iterator(ND, SingleDeclIndex);
711 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin());
715ResultBuilder::ShadowMapEntry::end()
const {
716 if (DeclOrVector.is<
const NamedDecl *>() || DeclOrVector.isNull())
719 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->end());
740 for (
const DeclContext *CommonAncestor = TargetContext;
741 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
742 CommonAncestor = CommonAncestor->getLookupParent()) {
743 if (CommonAncestor->isTransparentContext() ||
744 CommonAncestor->isFunctionOrMethod())
747 TargetParents.push_back(CommonAncestor);
751 while (!TargetParents.empty()) {
754 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(
Parent)) {
755 if (!Namespace->getIdentifier())
759 }
else if (
const auto *TD = dyn_cast<TagDecl>(
Parent))
790bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
791 bool &AsNestedNameSpecifier)
const {
792 AsNestedNameSpecifier =
false;
807 if (isa<ClassTemplateSpecializationDecl>(ND) ||
808 isa<ClassTemplatePartialSpecializationDecl>(ND))
812 if (isa<UsingDecl>(ND))
818 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
819 (isa<NamespaceDecl>(ND) && Filter != &ResultBuilder::IsNamespace &&
820 Filter != &ResultBuilder::IsNamespaceOrAlias && Filter !=
nullptr))
821 AsNestedNameSpecifier =
true;
824 if (Filter && !(this->*Filter)(Named)) {
826 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
827 IsNestedNameSpecifier(ND) &&
828 (Filter != &ResultBuilder::IsMember ||
829 (isa<CXXRecordDecl>(ND) &&
830 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
831 AsNestedNameSpecifier =
true;
861 R.QualifierIsInformative =
false;
865 R.Declaration->getDeclContext());
874 switch (cast<BuiltinType>(
T)->
getKind()) {
875 case BuiltinType::Void:
878 case BuiltinType::NullPtr:
881 case BuiltinType::Overload:
882 case BuiltinType::Dependent:
885 case BuiltinType::ObjCId:
886 case BuiltinType::ObjCClass:
887 case BuiltinType::ObjCSel:
900 case Type::BlockPointer:
903 case Type::LValueReference:
904 case Type::RValueReference:
907 case Type::ConstantArray:
908 case Type::IncompleteArray:
909 case Type::VariableArray:
910 case Type::DependentSizedArray:
913 case Type::DependentSizedExtVector:
915 case Type::ExtVector:
918 case Type::FunctionProto:
919 case Type::FunctionNoProto:
928 case Type::ObjCObject:
929 case Type::ObjCInterface:
930 case Type::ObjCObjectPointer:
943 if (
const auto *
Type = dyn_cast<TypeDecl>(ND))
944 return C.getTypeDeclType(
Type);
945 if (
const auto *Iface = dyn_cast<ObjCInterfaceDecl>(ND))
946 return C.getObjCInterfaceType(Iface);
951 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND))
952 T = Method->getSendResultType();
953 else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND))
954 T =
C.getTypeDeclType(cast<EnumDecl>(Enumerator->getDeclContext()));
955 else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND))
957 else if (
const auto *
Value = dyn_cast<ValueDecl>(ND))
973 if (
Pointer->getPointeeType()->isFunctionType()) {
982 T =
Block->getPointeeType();
997unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
1005 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
1006 if (ImplicitParam->getIdentifier() &&
1007 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
1014 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC)) {
1016 if (isa<CXXDestructorDecl>(ND))
1028 if (isa<EnumConstantDecl>(ND))
1034 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
1036 CompletionContext.
getKind() ==
1038 CompletionContext.
getKind() ==
1045void ResultBuilder::AdjustResultPriorityForDecl(
Result &R) {
1048 if (!PreferredSelector.
isNull())
1049 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
1050 if (PreferredSelector == Method->getSelector())
1055 if (!PreferredType.
isNull()) {
1065 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
1077 return Record->lookup(ConstructorName);
1080void ResultBuilder::MaybeAddConstructorResults(
Result R) {
1081 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
1088 Record = ClassTemplate->getTemplatedDecl();
1089 else if ((
Record = dyn_cast<CXXRecordDecl>(D))) {
1091 if (isa<ClassTemplateSpecializationDecl>(
Record))
1103 R.Declaration = Ctor;
1105 Results.push_back(R);
1110 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
1111 ND = Tmpl->getTemplatedDecl();
1112 return isa<CXXConstructorDecl>(ND);
1116 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
1118 if (R.Kind != Result::RK_Declaration) {
1120 Results.push_back(R);
1125 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1127 getBasePriority(
Using->getTargetDecl()),
1131 std::move(R.FixIts));
1133 MaybeAddResult(
Result, CurContext);
1140 bool AsNestedNameSpecifier =
false;
1141 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1148 ShadowMap &
SMap = ShadowMaps.back();
1149 ShadowMapEntry::iterator I, IEnd;
1150 ShadowMap::iterator NamePos =
SMap.find(R.Declaration->getDeclName());
1151 if (NamePos !=
SMap.end()) {
1152 I = NamePos->second.begin();
1153 IEnd = NamePos->second.end();
1156 for (; I != IEnd; ++I) {
1158 unsigned Index = I->second;
1161 Results[Index].Declaration = R.Declaration;
1171 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
1173 for (
SM = ShadowMaps.begin();
SM != SMEnd; ++
SM) {
1174 ShadowMapEntry::iterator I, IEnd;
1175 ShadowMap::iterator NamePos =
SM->find(R.Declaration->getDeclName());
1176 if (NamePos !=
SM->end()) {
1177 I = NamePos->second.begin();
1178 IEnd = NamePos->second.end();
1180 for (; I != IEnd; ++I) {
1182 if (I->first->hasTagIdentifierNamespace() &&
1190 I->first->getIdentifierNamespace() != IDNS)
1194 if (CheckHiddenResult(R, CurContext, I->first))
1202 if (!AllDeclsFound.insert(CanonDecl).second)
1207 if (AsNestedNameSpecifier) {
1208 R.StartsNestedNameSpecifier =
true;
1211 AdjustResultPriorityForDecl(R);
1214 if (R.QualifierIsInformative && !R.Qualifier &&
1215 !R.StartsNestedNameSpecifier) {
1216 const DeclContext *Ctx = R.Declaration->getDeclContext();
1217 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1220 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1222 SemaRef.
Context,
nullptr,
false,
1225 R.QualifierIsInformative =
false;
1230 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
1231 Results.push_back(R);
1233 if (!AsNestedNameSpecifier)
1234 MaybeAddConstructorResults(R);
1253 return OverloadCompare::BothViable;
1258 return OverloadCompare::BothViable;
1259 for (
unsigned I = 0, E = Candidate.
getNumParams(); I != E; ++I)
1260 if (Candidate.
parameters()[I]->getType().getCanonicalType() !=
1261 Incumbent.
parameters()[I]->getType().getCanonicalType())
1262 return OverloadCompare::BothViable;
1265 return OverloadCompare::BothViable;
1270 if (CandidateRef != IncumbentRef) {
1277 return CandidateRef ==
RQ_RValue ? OverloadCompare::Dominates
1278 : OverloadCompare::Dominated;
1286 if (CandidateSuperset == IncumbentSuperset)
1287 return OverloadCompare::BothViable;
1288 return IncumbentSuperset ? OverloadCompare::Dominates
1289 : OverloadCompare::Dominated;
1292bool ResultBuilder::canCxxMethodBeCalled(
const CXXMethodDecl *Method,
1298 const auto *CurrentClassScope = [&]() ->
const CXXRecordDecl * {
1300 const auto *CtxMethod = llvm::dyn_cast<CXXMethodDecl>(Ctx);
1301 if (CtxMethod && !CtxMethod->getParent()->isLambda()) {
1302 return CtxMethod->getParent();
1309 bool FunctionCanBeCall =
1310 CurrentClassScope &&
1311 (CurrentClassScope == Method->
getParent() ||
1315 if (FunctionCanBeCall)
1320 BaseExprType.
isNull() ?
nullptr
1324 MaybeDerived == MaybeBase || MaybeDerived->
isDerivedFrom(MaybeBase);
1327 return FunctionCanBeCall;
1330bool ResultBuilder::canFunctionBeCalled(
const NamedDecl *ND,
1341 if (
const auto *FuncTmpl = dyn_cast<FunctionTemplateDecl>(ND)) {
1342 ND = FuncTmpl->getTemplatedDecl();
1344 const auto *Method = dyn_cast<CXXMethodDecl>(ND);
1345 if (Method && !Method->
isStatic()) {
1346 return canCxxMethodBeCalled(Method, BaseExprType);
1353 NamedDecl *Hiding,
bool InBaseClass =
false,
1355 if (R.Kind != Result::RK_Declaration) {
1357 Results.push_back(R);
1362 if (
const auto *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1364 getBasePriority(
Using->getTargetDecl()),
1368 std::move(R.FixIts));
1370 AddResult(
Result, CurContext, Hiding,
false,
1375 bool AsNestedNameSpecifier =
false;
1376 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1383 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
1387 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
1392 if (AsNestedNameSpecifier) {
1393 R.StartsNestedNameSpecifier =
true;
1395 }
else if (Filter == &ResultBuilder::IsMember && !R.Qualifier &&
1398 R.Declaration->getDeclContext()->getRedeclContext()))
1399 R.QualifierIsInformative =
true;
1402 if (R.QualifierIsInformative && !R.Qualifier &&
1403 !R.StartsNestedNameSpecifier) {
1404 const DeclContext *Ctx = R.Declaration->getDeclContext();
1405 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1408 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1410 SemaRef.
Context,
nullptr,
false,
1413 R.QualifierIsInformative =
false;
1420 AdjustResultPriorityForDecl(R);
1422 if (HasObjectTypeQualifiers)
1423 if (
const auto *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1426 if (ObjectTypeQualifiers == MethodQuals)
1428 else if (ObjectTypeQualifiers - MethodQuals) {
1450 auto &OverloadSet = OverloadMap[std::make_pair(
1452 for (
const DeclIndexPair Entry : OverloadSet) {
1453 Result &Incumbent = Results[Entry.second];
1455 *cast<CXXMethodDecl>(Incumbent.Declaration),
1456 ObjectTypeQualifiers, ObjectKind)) {
1457 case OverloadCompare::Dominates:
1461 Incumbent = std::move(R);
1463 case OverloadCompare::Dominated:
1466 case OverloadCompare::BothViable:
1470 OverloadSet.Add(Method, Results.size());
1473 R.FunctionCanBeCall = canFunctionBeCalled(R.getDeclaration(), BaseExprType);
1476 Results.push_back(R);
1478 if (!AsNestedNameSpecifier)
1479 MaybeAddConstructorResults(R);
1482void ResultBuilder::AddResult(
Result R) {
1483 assert(R.Kind != Result::RK_Declaration &&
1484 "Declaration results need more context");
1485 Results.push_back(R);
1489void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1492void ResultBuilder::ExitScope() {
1493 ShadowMaps.pop_back();
1498bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1507 if (isa<ObjCIvarDecl>(ND))
1516bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1518 if (isa<TypeDecl>(ND))
1523 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1524 if (!
ID->getDefinition())
1532 if (isa<ObjCIvarDecl>(ND))
1539bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1540 if (!IsOrdinaryNonTypeName(ND))
1544 if (VD->getType()->isIntegralOrEnumerationType())
1552bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1560 !isa<FunctionTemplateDecl>(ND) && !isa<ObjCPropertyDecl>(ND);
1565bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1567 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1568 ND = ClassTemplate->getTemplatedDecl();
1574bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1575 return isa<EnumDecl>(ND);
1579bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1581 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1582 ND = ClassTemplate->getTemplatedDecl();
1585 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1594bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1596 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1597 ND = ClassTemplate->getTemplatedDecl();
1599 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1606bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1607 return isa<NamespaceDecl>(ND);
1612bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1617bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1619 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1625bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1627 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1628 isa<ObjCPropertyDecl>(ND);
1632 T =
C.getCanonicalType(
T);
1634 case Type::ObjCObject:
1635 case Type::ObjCInterface:
1636 case Type::ObjCObjectPointer:
1640 switch (cast<BuiltinType>(
T)->
getKind()) {
1641 case BuiltinType::ObjCId:
1642 case BuiltinType::ObjCClass:
1643 case BuiltinType::ObjCSel:
1655 if (!
C.getLangOpts().CPlusPlus)
1664bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1673bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1675 if (IsObjCMessageReceiver(ND))
1678 const auto *Var = dyn_cast<VarDecl>(ND);
1682 return Var->hasLocalStorage() && !Var->hasAttr<BlocksAttr>();
1685bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1686 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1687 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1700bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1706bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1707 return isa<ObjCIvarDecl>(ND);
1715 ResultBuilder &Results;
1721 std::vector<FixItHint> FixIts;
1724 CodeCompletionDeclConsumer(
1725 ResultBuilder &Results,
DeclContext *InitialLookupCtx,
1727 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1728 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1729 FixIts(
std::move(FixIts)) {
1730 NamingClass = llvm::dyn_cast<CXXRecordDecl>(InitialLookupCtx);
1733 auto ThisType = Results.getSema().getCurrentThisType();
1734 if (!ThisType.isNull()) {
1735 assert(ThisType->isPointerType());
1741 this->BaseType = BaseType;
1745 bool InBaseClass)
override {
1748 Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass, BaseType);
1752 Results.addVisitedContext(Ctx);
1761 auto *NamingClass = this->NamingClass;
1762 QualType BaseType = this->BaseType;
1763 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1778 NamingClass =
nullptr;
1781 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1788 ResultBuilder &Results) {
1814 Results.getCodeCompletionTUInfo());
1815 if (LangOpts.CPlusPlus) {
1823 Builder.AddTypedTextChunk(
"typename");
1825 Builder.AddPlaceholderChunk(
"name");
1826 Results.AddResult(
Result(Builder.TakeString()));
1828 if (LangOpts.CPlusPlus11) {
1833 Builder.AddTypedTextChunk(
"decltype");
1835 Builder.AddPlaceholderChunk(
"expression");
1837 Results.AddResult(
Result(Builder.TakeString()));
1843 if (LangOpts.GNUKeywords) {
1849 Builder.AddTypedTextChunk(
"typeof");
1851 Builder.AddPlaceholderChunk(
"expression");
1852 Results.AddResult(
Result(Builder.TakeString()));
1854 Builder.AddTypedTextChunk(
"typeof");
1856 Builder.AddPlaceholderChunk(
"type");
1858 Results.AddResult(
Result(Builder.TakeString()));
1869 const LangOptions &LangOpts, ResultBuilder &Results) {
1874 Results.AddResult(
Result(
"extern"));
1875 Results.AddResult(
Result(
"static"));
1877 if (LangOpts.CPlusPlus11) {
1882 Builder.AddTypedTextChunk(
"alignas");
1884 Builder.AddPlaceholderChunk(
"expression");
1886 Results.AddResult(
Result(Builder.TakeString()));
1888 Results.AddResult(
Result(
"constexpr"));
1889 Results.AddResult(
Result(
"thread_local"));
1895 const LangOptions &LangOpts, ResultBuilder &Results) {
1900 if (LangOpts.CPlusPlus) {
1901 Results.AddResult(
Result(
"explicit"));
1902 Results.AddResult(
Result(
"friend"));
1903 Results.AddResult(
Result(
"mutable"));
1904 Results.AddResult(
Result(
"virtual"));
1912 if (LangOpts.CPlusPlus || LangOpts.C99)
1913 Results.AddResult(
Result(
"inline"));
1933 ResultBuilder &Results,
bool NeedAt);
1935 ResultBuilder &Results,
bool NeedAt);
1937 ResultBuilder &Results,
bool NeedAt);
1942 Results.getCodeCompletionTUInfo());
1943 Builder.AddTypedTextChunk(
"typedef");
1945 Builder.AddPlaceholderChunk(
"type");
1947 Builder.AddPlaceholderChunk(
"name");
1954 ResultBuilder &Results) {
1955 Builder.AddTypedTextChunk(
"using");
1957 Builder.AddPlaceholderChunk(
"name");
1959 Builder.AddPlaceholderChunk(
"type");
1982 return LangOpts.CPlusPlus;
1989 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
1992 llvm_unreachable(
"Invalid ParserCompletionContext!");
2019 if (!
T.getLocalQualifiers()) {
2022 return BT->getNameAsCString(Policy);
2025 if (
const TagType *TagT = dyn_cast<TagType>(
T))
2026 if (
TagDecl *Tag = TagT->getDecl())
2027 if (!Tag->hasNameForLinkage()) {
2028 switch (Tag->getTagKind()) {
2030 return "struct <anonymous>";
2032 return "__interface <anonymous>";
2034 return "class <anonymous>";
2036 return "union <anonymous>";
2038 return "enum <anonymous>";
2045 T.getAsStringInternal(
Result, Policy);
2046 return Allocator.CopyString(
Result);
2058 Builder.AddResultTypeChunk(
2060 Builder.AddTypedTextChunk(
"this");
2065 ResultBuilder &Results,
2067 if (!LangOpts.CPlusPlus11)
2070 Builder.AddTypedTextChunk(
"static_assert");
2072 Builder.AddPlaceholderChunk(
"expression");
2074 Builder.AddPlaceholderChunk(
"message");
2083 Sema &S = Results.getSema();
2084 const auto *CR = llvm::dyn_cast<CXXRecordDecl>(S.
CurContext);
2090 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
2091 for (
auto *Method : CR->methods()) {
2094 Overrides[Method->
getName()].push_back(Method);
2097 for (
const auto &
Base : CR->bases()) {
2098 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
2101 for (
auto *Method : BR->methods()) {
2104 const auto it = Overrides.find(Method->
getName());
2105 bool IsOverriden =
false;
2106 if (it != Overrides.end()) {
2107 for (
auto *MD : it->second) {
2120 std::string OverrideSignature;
2121 llvm::raw_string_ostream OS(OverrideSignature);
2127 false, CCContext, Policy);
2137 Scope *S,
Sema &SemaRef, ResultBuilder &Results) {
2145 if (Results.includeCodePatterns()) {
2147 Builder.AddTypedTextChunk(
"namespace");
2149 Builder.AddPlaceholderChunk(
"identifier");
2153 Builder.AddPlaceholderChunk(
"declarations");
2156 Results.AddResult(
Result(Builder.TakeString()));
2160 Builder.AddTypedTextChunk(
"namespace");
2162 Builder.AddPlaceholderChunk(
"name");
2164 Builder.AddPlaceholderChunk(
"namespace");
2166 Results.AddResult(
Result(Builder.TakeString()));
2169 Builder.AddTypedTextChunk(
"using namespace");
2171 Builder.AddPlaceholderChunk(
"identifier");
2173 Results.AddResult(
Result(Builder.TakeString()));
2176 Builder.AddTypedTextChunk(
"asm");
2178 Builder.AddPlaceholderChunk(
"string-literal");
2180 Results.AddResult(
Result(Builder.TakeString()));
2182 if (Results.includeCodePatterns()) {
2184 Builder.AddTypedTextChunk(
"template");
2186 Builder.AddPlaceholderChunk(
"declaration");
2187 Results.AddResult(
Result(Builder.TakeString()));
2202 Builder.AddTypedTextChunk(
"using");
2204 Builder.AddPlaceholderChunk(
"qualifier");
2205 Builder.AddTextChunk(
"::");
2206 Builder.AddPlaceholderChunk(
"name");
2208 Results.AddResult(
Result(Builder.TakeString()));
2215 Builder.AddTypedTextChunk(
"using typename");
2217 Builder.AddPlaceholderChunk(
"qualifier");
2218 Builder.AddTextChunk(
"::");
2219 Builder.AddPlaceholderChunk(
"name");
2221 Results.AddResult(
Result(Builder.TakeString()));
2229 bool IsNotInheritanceScope = !S->isClassInheritanceScope();
2231 Builder.AddTypedTextChunk(
"public");
2232 if (IsNotInheritanceScope && Results.includeCodePatterns())
2234 Results.AddResult(
Result(Builder.TakeString()));
2237 Builder.AddTypedTextChunk(
"protected");
2238 if (IsNotInheritanceScope && Results.includeCodePatterns())
2240 Results.AddResult(
Result(Builder.TakeString()));
2243 Builder.AddTypedTextChunk(
"private");
2244 if (IsNotInheritanceScope && Results.includeCodePatterns())
2246 Results.AddResult(
Result(Builder.TakeString()));
2259 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
2261 Builder.AddTypedTextChunk(
"template");
2263 Builder.AddPlaceholderChunk(
"parameters");
2265 Results.AddResult(
Result(Builder.TakeString()));
2298 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
2300 Builder.AddTypedTextChunk(
"try");
2304 Builder.AddPlaceholderChunk(
"statements");
2308 Builder.AddTextChunk(
"catch");
2311 Builder.AddPlaceholderChunk(
"declaration");
2316 Builder.AddPlaceholderChunk(
"statements");
2319 Results.AddResult(
Result(Builder.TakeString()));
2324 if (Results.includeCodePatterns()) {
2326 Builder.AddTypedTextChunk(
"if");
2330 Builder.AddPlaceholderChunk(
"condition");
2332 Builder.AddPlaceholderChunk(
"expression");
2337 Builder.AddPlaceholderChunk(
"statements");
2340 Results.AddResult(
Result(Builder.TakeString()));
2343 Builder.AddTypedTextChunk(
"switch");
2347 Builder.AddPlaceholderChunk(
"condition");
2349 Builder.AddPlaceholderChunk(
"expression");
2354 Builder.AddPlaceholderChunk(
"cases");
2357 Results.AddResult(
Result(Builder.TakeString()));
2364 Builder.AddTypedTextChunk(
"case");
2366 Builder.AddPlaceholderChunk(
"expression");
2368 Results.AddResult(
Result(Builder.TakeString()));
2371 Builder.AddTypedTextChunk(
"default");
2373 Results.AddResult(
Result(Builder.TakeString()));
2376 if (Results.includeCodePatterns()) {
2378 Builder.AddTypedTextChunk(
"while");
2382 Builder.AddPlaceholderChunk(
"condition");
2384 Builder.AddPlaceholderChunk(
"expression");
2389 Builder.AddPlaceholderChunk(
"statements");
2392 Results.AddResult(
Result(Builder.TakeString()));
2395 Builder.AddTypedTextChunk(
"do");
2399 Builder.AddPlaceholderChunk(
"statements");
2402 Builder.AddTextChunk(
"while");
2405 Builder.AddPlaceholderChunk(
"expression");
2407 Results.AddResult(
Result(Builder.TakeString()));
2410 Builder.AddTypedTextChunk(
"for");
2414 Builder.AddPlaceholderChunk(
"init-statement");
2416 Builder.AddPlaceholderChunk(
"init-expression");
2419 Builder.AddPlaceholderChunk(
"condition");
2422 Builder.AddPlaceholderChunk(
"inc-expression");
2427 Builder.AddPlaceholderChunk(
"statements");
2430 Results.AddResult(
Result(Builder.TakeString()));
2434 Builder.AddTypedTextChunk(
"for");
2437 Builder.AddPlaceholderChunk(
"range-declaration");
2440 Builder.AddTextChunk(
"in");
2444 Builder.AddPlaceholderChunk(
"range-expression");
2449 Builder.AddPlaceholderChunk(
"statements");
2452 Results.AddResult(
Result(Builder.TakeString()));
2456 if (S->getContinueParent()) {
2458 Builder.AddTypedTextChunk(
"continue");
2460 Results.AddResult(
Result(Builder.TakeString()));
2463 if (S->getBreakParent()) {
2465 Builder.AddTypedTextChunk(
"break");
2467 Results.AddResult(
Result(Builder.TakeString()));
2473 ReturnType =
Function->getReturnType();
2474 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
2480 Builder.AddTypedTextChunk(
"return");
2482 Results.AddResult(
Result(Builder.TakeString()));
2484 assert(!ReturnType.
isNull());
2486 Builder.AddTypedTextChunk(
"return");
2488 Builder.AddPlaceholderChunk(
"expression");
2490 Results.AddResult(
Result(Builder.TakeString()));
2493 Builder.AddTypedTextChunk(
"return true");
2495 Results.AddResult(
Result(Builder.TakeString()));
2497 Builder.AddTypedTextChunk(
"return false");
2499 Results.AddResult(
Result(Builder.TakeString()));
2504 Builder.AddTypedTextChunk(
"return nullptr");
2506 Results.AddResult(
Result(Builder.TakeString()));
2511 Builder.AddTypedTextChunk(
"goto");
2513 Builder.AddPlaceholderChunk(
"label");
2515 Results.AddResult(
Result(Builder.TakeString()));
2518 Builder.AddTypedTextChunk(
"using namespace");
2520 Builder.AddPlaceholderChunk(
"identifier");
2522 Results.AddResult(
Result(Builder.TakeString()));
2539 Builder.AddTypedTextChunk(
"__bridge");
2541 Builder.AddPlaceholderChunk(
"type");
2543 Builder.AddPlaceholderChunk(
"expression");
2544 Results.AddResult(
Result(Builder.TakeString()));
2547 Builder.AddTypedTextChunk(
"__bridge_transfer");
2549 Builder.AddPlaceholderChunk(
"Objective-C type");
2551 Builder.AddPlaceholderChunk(
"expression");
2552 Results.AddResult(
Result(Builder.TakeString()));
2555 Builder.AddTypedTextChunk(
"__bridge_retained");
2557 Builder.AddPlaceholderChunk(
"CF type");
2559 Builder.AddPlaceholderChunk(
"expression");
2560 Results.AddResult(
Result(Builder.TakeString()));
2571 Builder.AddResultTypeChunk(
"bool");
2572 Builder.AddTypedTextChunk(
"true");
2573 Results.AddResult(
Result(Builder.TakeString()));
2576 Builder.AddResultTypeChunk(
"bool");
2577 Builder.AddTypedTextChunk(
"false");
2578 Results.AddResult(
Result(Builder.TakeString()));
2582 Builder.AddTypedTextChunk(
"dynamic_cast");
2584 Builder.AddPlaceholderChunk(
"type");
2587 Builder.AddPlaceholderChunk(
"expression");
2589 Results.AddResult(
Result(Builder.TakeString()));
2593 Builder.AddTypedTextChunk(
"static_cast");
2595 Builder.AddPlaceholderChunk(
"type");
2598 Builder.AddPlaceholderChunk(
"expression");
2600 Results.AddResult(
Result(Builder.TakeString()));
2603 Builder.AddTypedTextChunk(
"reinterpret_cast");
2605 Builder.AddPlaceholderChunk(
"type");
2608 Builder.AddPlaceholderChunk(
"expression");
2610 Results.AddResult(
Result(Builder.TakeString()));
2613 Builder.AddTypedTextChunk(
"const_cast");
2615 Builder.AddPlaceholderChunk(
"type");
2618 Builder.AddPlaceholderChunk(
"expression");
2620 Results.AddResult(
Result(Builder.TakeString()));
2624 Builder.AddResultTypeChunk(
"std::type_info");
2625 Builder.AddTypedTextChunk(
"typeid");
2627 Builder.AddPlaceholderChunk(
"expression-or-type");
2629 Results.AddResult(
Result(Builder.TakeString()));
2633 Builder.AddTypedTextChunk(
"new");
2635 Builder.AddPlaceholderChunk(
"type");
2637 Builder.AddPlaceholderChunk(
"expressions");
2639 Results.AddResult(
Result(Builder.TakeString()));
2642 Builder.AddTypedTextChunk(
"new");
2644 Builder.AddPlaceholderChunk(
"type");
2646 Builder.AddPlaceholderChunk(
"size");
2649 Builder.AddPlaceholderChunk(
"expressions");
2651 Results.AddResult(
Result(Builder.TakeString()));
2654 Builder.AddResultTypeChunk(
"void");
2655 Builder.AddTypedTextChunk(
"delete");
2657 Builder.AddPlaceholderChunk(
"expression");
2658 Results.AddResult(
Result(Builder.TakeString()));
2661 Builder.AddResultTypeChunk(
"void");
2662 Builder.AddTypedTextChunk(
"delete");
2667 Builder.AddPlaceholderChunk(
"expression");
2668 Results.AddResult(
Result(Builder.TakeString()));
2672 Builder.AddResultTypeChunk(
"void");
2673 Builder.AddTypedTextChunk(
"throw");
2675 Builder.AddPlaceholderChunk(
"expression");
2676 Results.AddResult(
Result(Builder.TakeString()));
2683 Builder.AddResultTypeChunk(
"std::nullptr_t");
2684 Builder.AddTypedTextChunk(
"nullptr");
2685 Results.AddResult(
Result(Builder.TakeString()));
2688 Builder.AddResultTypeChunk(
"size_t");
2689 Builder.AddTypedTextChunk(
"alignof");
2691 Builder.AddPlaceholderChunk(
"type");
2693 Results.AddResult(
Result(Builder.TakeString()));
2696 Builder.AddResultTypeChunk(
"bool");
2697 Builder.AddTypedTextChunk(
"noexcept");
2699 Builder.AddPlaceholderChunk(
"expression");
2701 Results.AddResult(
Result(Builder.TakeString()));
2704 Builder.AddResultTypeChunk(
"size_t");
2705 Builder.AddTypedTextChunk(
"sizeof...");
2707 Builder.AddPlaceholderChunk(
"parameter-pack");
2709 Results.AddResult(
Result(Builder.TakeString()));
2718 if (ID->getSuperClass()) {
2719 std::string SuperType;
2720 SuperType = ID->getSuperClass()->getNameAsString();
2721 if (Method->isInstanceMethod())
2724 Builder.AddResultTypeChunk(Allocator.CopyString(SuperType));
2725 Builder.AddTypedTextChunk(
"super");
2726 Results.AddResult(
Result(Builder.TakeString()));
2735 Builder.AddResultTypeChunk(
"size_t");
2737 Builder.AddTypedTextChunk(
"alignof");
2739 Builder.AddTypedTextChunk(
"_Alignof");
2741 Builder.AddPlaceholderChunk(
"type");
2743 Results.AddResult(
Result(Builder.TakeString()));
2748 Builder.AddResultTypeChunk(
"nullptr_t");
2749 Builder.AddTypedTextChunk(
"nullptr");
2750 Results.AddResult(
Result(Builder.TakeString()));
2754 Builder.AddResultTypeChunk(
"size_t");
2755 Builder.AddTypedTextChunk(
"sizeof");
2757 Builder.AddPlaceholderChunk(
"expression-or-type");
2759 Results.AddResult(
Result(Builder.TakeString()));
2772 Results.AddResult(
Result(
"operator"));
2793 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2795 T = Method->getSendResultType(BaseType);
2798 }
else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2801 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2803 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2805 T = Ivar->getUsageType(BaseType);
2807 T = Ivar->getType();
2808 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
2810 }
else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND)) {
2820 Result.AddResultTypeChunk(
2827 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2828 if (Sentinel->getSentinel() == 0) {
2830 Result.AddTextChunk(
", nil");
2832 Result.AddTextChunk(
", NULL");
2834 Result.AddTextChunk(
", (void*)0");
2855 switch (*nullability) {
2865 Result +=
"null_unspecified ";
2869 llvm_unreachable(
"Not supported as a context-sensitive keyword!");
2886 bool SuppressBlock =
false) {
2892 if (!SuppressBlock) {
2895 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2908 TL = AttrTL.getModifiedLoc();
2927 bool SuppressBlockName =
false,
bool SuppressBlock =
false,
2932 bool SuppressName =
false,
bool SuppressBlock =
false,
2940 if (
const auto *PVD = dyn_cast<ParmVarDecl>(Param))
2941 ObjCQual = PVD->getObjCDeclQualifier();
2942 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2949 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2956 if (ObjCMethodParam) {
2975 if (!
Block && ObjCMethodParam &&
2976 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
2977 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
2978 ->findPropertyDecl(
false))
2992 if (ObjCMethodParam) {
2997 if (
Result.back() !=
')')
3011 false, SuppressBlock,
3027 bool SuppressBlockName,
bool SuppressBlock,
3035 if (!ResultType->
isVoidType() || SuppressBlock)
3040 if (!BlockProto ||
Block.getNumParams() == 0) {
3047 for (
unsigned I = 0, N =
Block.getNumParams(); I != N; ++I) {
3060 if (SuppressBlock) {
3063 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3072 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3092 if (srcText.empty() || srcText ==
"=") {
3098 std::string DefValue(srcText.str());
3101 if (DefValue.at(0) !=
'=') {
3105 return " = " + DefValue;
3107 return " " + DefValue;
3116 bool InOptional =
false) {
3117 bool FirstParameter =
true;
3119 for (
unsigned P = Start, N =
Function->getNumParams();
P != N; ++
P) {
3126 Result.getCodeCompletionTUInfo());
3127 if (!FirstParameter)
3135 FirstParameter =
false;
3147 if (
Function->isVariadic() &&
P == N - 1)
3148 PlaceholderStr +=
", ...";
3151 Result.AddPlaceholderChunk(
3152 Result.getAllocator().CopyString(PlaceholderStr));
3156 if (Proto->isVariadic()) {
3157 if (Proto->getNumParams() == 0)
3158 Result.AddPlaceholderChunk(
"...");
3168 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false) {
3169 bool FirstParameter =
true;
3178 PEnd = Params->
begin() + MaxParameters;
3181 bool HasDefaultArg =
false;
3182 std::string PlaceholderStr;
3184 if (TTP->wasDeclaredWithTypename())
3185 PlaceholderStr =
"typename";
3186 else if (
const auto *TC = TTP->getTypeConstraint()) {
3187 llvm::raw_string_ostream OS(PlaceholderStr);
3188 TC->print(OS, Policy);
3191 PlaceholderStr =
"class";
3193 if (TTP->getIdentifier()) {
3194 PlaceholderStr +=
' ';
3195 PlaceholderStr += TTP->getIdentifier()->deuglifiedName();
3198 HasDefaultArg = TTP->hasDefaultArgument();
3200 dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
3201 if (NTTP->getIdentifier())
3202 PlaceholderStr = std::string(NTTP->getIdentifier()->deuglifiedName());
3203 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
3204 HasDefaultArg = NTTP->hasDefaultArgument();
3206 assert(isa<TemplateTemplateParmDecl>(*
P));
3211 PlaceholderStr =
"template<...> class";
3213 PlaceholderStr +=
' ';
3220 if (HasDefaultArg && !InDefaultArg) {
3224 Result.getCodeCompletionTUInfo());
3225 if (!FirstParameter)
3228 P - Params->
begin(),
true);
3233 InDefaultArg =
false;
3236 FirstParameter =
false;
3241 Result.AddPlaceholderChunk(
3242 Result.getAllocator().CopyString(PlaceholderStr));
3250 bool QualifierIsInformative,
3256 std::string PrintedNNS;
3258 llvm::raw_string_ostream OS(PrintedNNS);
3259 Qualifier->print(OS, Policy);
3261 if (QualifierIsInformative)
3262 Result.AddInformativeChunk(
Result.getAllocator().CopyString(PrintedNNS));
3264 Result.AddTextChunk(
Result.getAllocator().CopyString(PrintedNNS));
3271 if (!Proto || !Proto->getMethodQuals())
3277 if (Proto->getMethodQuals().hasOnlyConst()) {
3278 Result.AddInformativeChunk(
" const");
3282 if (Proto->getMethodQuals().hasOnlyVolatile()) {
3283 Result.AddInformativeChunk(
" volatile");
3287 if (Proto->getMethodQuals().hasOnlyRestrict()) {
3288 Result.AddInformativeChunk(
" restrict");
3293 std::string QualsStr;
3294 if (Proto->isConst())
3295 QualsStr +=
" const";
3296 if (Proto->isVolatile())
3297 QualsStr +=
" volatile";
3298 if (Proto->isRestrict())
3299 QualsStr +=
" restrict";
3300 Result.AddInformativeChunk(
Result.getAllocator().CopyString(QualsStr));
3311 switch (Name.getNameKind()) {
3313 const char *OperatorName =
nullptr;
3314 switch (Name.getCXXOverloadedOperator()) {
3316 case OO_Conditional:
3318 OperatorName =
"operator";
3321#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
3323 OperatorName = "operator" Spelling; \
3325#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly)
3326#include "clang/Basic/OperatorKinds.def"
3329 OperatorName =
"operator new";
3332 OperatorName =
"operator delete";
3335 OperatorName =
"operator new[]";
3337 case OO_Array_Delete:
3338 OperatorName =
"operator delete[]";
3341 OperatorName =
"operator()";
3344 OperatorName =
"operator[]";
3347 Result.AddTypedTextChunk(OperatorName);
3355 Result.AddTypedTextChunk(
3368 QualType Ty = Name.getCXXNameType();
3370 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
3372 Record = InjectedTy->getDecl();
3374 Result.AddTypedTextChunk(
3379 Result.AddTypedTextChunk(
3380 Result.getAllocator().CopyString(
Record->getNameAsString()));
3394 bool IncludeBriefComments) {
3396 CCTUInfo, IncludeBriefComments);
3408 return Result.TakeString();
3419 Result.AddPlaceholderChunk(
"...");
3433 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3438 Result.AddPlaceholderChunk(
3439 Result.getAllocator().CopyString((*A)->getName()));
3442 return Result.TakeString();
3454 bool IncludeBriefComments) {
3470 Result.addBriefComment(RC->getBriefText(Ctx));
3480 return Result.TakeString();
3484 PP, Ctx,
Result, IncludeBriefComments, CCContext, Policy);
3488 std::string &BeforeName,
3489 std::string &NameAndSignature) {
3490 bool SeenTypedChunk =
false;
3491 for (
auto &Chunk : CCS) {
3493 assert(SeenTypedChunk &&
"optional parameter before name");
3500 NameAndSignature += Chunk.Text;
3502 BeforeName += Chunk.Text;
3514 std::string BeforeName;
3515 std::string NameAndSignature;
3518 NameAndSignature +=
" override";
3520 Result.AddTextChunk(
Result.getAllocator().CopyString(BeforeName));
3522 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(NameAndSignature));
3523 return Result.TakeString();
3529 const auto *VD = dyn_cast<VarDecl>(ND);
3532 const auto *
RecordDecl = VD->getType()->getAsCXXRecordDecl();
3545 if (IncludeBriefComments) {
3548 Result.addBriefComment(RC->getBriefText(Ctx));
3553 Result.AddTypedTextChunk(
3555 Result.AddTextChunk(
"::");
3556 return Result.TakeString();
3560 Result.AddAnnotation(
Result.getAllocator().CopyString(I->getAnnotation()));
3573 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND)) {
3574 AddFunctionTypeAndResult(
Function);
3575 return Result.TakeString();
3578 if (
const auto *CallOperator =
3580 AddFunctionTypeAndResult(CallOperator);
3581 return Result.TakeString();
3587 dyn_cast<FunctionTemplateDecl>(ND)) {
3598 llvm::SmallBitVector Deduced(FunTmpl->getTemplateParameters()->size());
3603 unsigned LastDeducibleArgument;
3604 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
3605 --LastDeducibleArgument) {
3606 if (!Deduced[LastDeducibleArgument - 1]) {
3610 bool HasDefaultArg =
false;
3611 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3612 LastDeducibleArgument - 1);
3614 HasDefaultArg = TTP->hasDefaultArgument();
3616 dyn_cast<NonTypeTemplateParmDecl>(Param))
3617 HasDefaultArg = NTTP->hasDefaultArgument();
3619 assert(isa<TemplateTemplateParmDecl>(Param));
3621 cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
3644 LastDeducibleArgument);
3653 return Result.TakeString();
3656 if (
const auto *Template = dyn_cast<TemplateDecl>(ND)) {
3659 Result.AddTypedTextChunk(
3660 Result.getAllocator().CopyString(Template->getNameAsString()));
3664 return Result.TakeString();
3667 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3668 Selector Sel = Method->getSelector();
3670 Result.AddTypedTextChunk(
3672 return Result.TakeString();
3678 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(SelName));
3680 Result.AddInformativeChunk(
Result.getAllocator().CopyString(SelName));
3685 Result.AddTypedTextChunk(
"");
3692 P != PEnd && Idx < Sel.
getNumArgs(); (
void)++
P, ++Idx) {
3711 QualType ParamType = (*P)->getType();
3712 std::optional<ArrayRef<QualType>> ObjCSubsts;
3728 Arg += II->getName();
3735 Result.AddTextChunk(
Result.getAllocator().CopyString(Arg));
3737 Result.AddInformativeChunk(
Result.getAllocator().CopyString(Arg));
3739 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3745 Result.AddTextChunk(
", ...");
3747 Result.AddInformativeChunk(
", ...");
3749 Result.AddPlaceholderChunk(
", ...");
3755 return Result.TakeString();
3762 Result.AddTypedTextChunk(
3764 return Result.TakeString();
3775 const auto *M = dyn_cast<ObjCMethodDecl>(ND);
3787 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
3788 if (!M || !M->isPropertyAccessor())
3811 auto FDecl =
Result.getFunction();
3814 if (ArgIndex < FDecl->getNumParams())
3822 unsigned CurrentArg) {
3823 unsigned ChunkIndex = 0;
3824 auto AddChunk = [&](llvm::StringRef Placeholder) {
3827 const char *
Copy =
Result.getAllocator().CopyString(Placeholder);
3828 if (ChunkIndex == CurrentArg)
3836 if (
auto *CRD = llvm::dyn_cast<CXXRecordDecl>(RD)) {
3837 for (
const auto &
Base : CRD->bases())
3838 AddChunk(
Base.getType().getAsString(Policy));
3840 for (
const auto &Field : RD->
fields())
3850 unsigned CurrentArg,
unsigned Start = 0,
bool InOptional =
false) {
3856 bool FirstParameter =
true;
3857 unsigned NumParams =
3860 for (
unsigned P = Start;
P != NumParams; ++
P) {
3865 Result.getCodeCompletionTUInfo());
3866 if (!FirstParameter)
3870 PrototypeLoc, Opt, CurrentArg,
P,
3877 FirstParameter =
false;
3884 std::string Placeholder;
3885 assert(P < Prototype->getNumParams());
3894 Placeholder =
Prototype->getParamType(
P).getAsString(Policy);
3897 if (
P == CurrentArg)
3898 Result.AddCurrentParameterChunk(
3899 Result.getAllocator().CopyString(Placeholder));
3901 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Placeholder));
3906 Result.getCodeCompletionTUInfo());
3907 if (!FirstParameter)
3910 if (CurrentArg < NumParams)
3922 if (
const auto *
Type = dyn_cast<TemplateTypeParmDecl>(Param)) {
3924 }
else if (
const auto *NonType = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3925 Optional = NonType->hasDefaultArgument();
3926 }
else if (
const auto *Template = dyn_cast<TemplateTemplateParmDecl>(Param)) {
3927 Optional = Template->hasDefaultArgument();
3930 llvm::raw_string_ostream OS(
Result);
3931 Param->
print(OS, Policy);
3937 if (
const auto *CTD = dyn_cast<ClassTemplateDecl>(TD))
3938 return CTD->getTemplatedDecl()->getKindName().str();
3939 if (
const auto *VTD = dyn_cast<VarTemplateDecl>(TD))
3940 return VTD->getTemplatedDecl()->getType().getAsString(Policy);
3941 if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(TD))
3942 return FTD->getTemplatedDecl()->getReturnType().getAsString(Policy);
3943 if (isa<TypeAliasTemplateDecl>(TD))
3945 if (isa<TemplateTemplateParmDecl>(TD))
3947 if (isa<ConceptDecl>(TD))
3957 Builder.getCodeCompletionTUInfo());
3959 if (!ResultType.empty())
3960 Builder.AddResultTypeChunk(Builder.getAllocator().CopyString(ResultType));
3961 Builder.AddTextChunk(
3967 for (
unsigned I = 0; I < Params.size(); ++I) {
3969 std::string Placeholder =
3972 Current = &OptionalBuilder;
3975 Current->AddChunk(I == CurrentArg
3978 Current->getAllocator().CopyString(Placeholder));
3981 if (Current == &OptionalBuilder)
3982 Builder.AddOptionalChunk(OptionalBuilder.
TakeString());
3986 if (isa<FunctionTemplateDecl>(TD))
3987 Builder.AddInformativeChunk(
"()");
3988 return Builder.TakeString();
3995 bool Braced)
const {
4019 if (IncludeBriefComments) {
4026 llvm::raw_string_ostream OS(Name);
4028 Result.AddTextChunk(
Result.getAllocator().CopyString(OS.str()));
4031 Result.AddResultTypeChunk(
Result.getAllocator().CopyString(
4046 return Result.TakeString();
4051 bool PreferredTypeIsPointer) {
4055 if (MacroName ==
"nil" || MacroName ==
"NULL" || MacroName ==
"Nil") {
4057 if (PreferredTypeIsPointer)
4061 else if (MacroName ==
"YES" || MacroName ==
"NO" || MacroName ==
"true" ||
4062 MacroName ==
"false")
4065 else if (MacroName ==
"bool")
4078 case Decl::EnumConstant:
4082 case Decl::Function:
4084 case Decl::ObjCCategory:
4086 case Decl::ObjCCategoryImpl:
4088 case Decl::ObjCImplementation:
4091 case Decl::ObjCInterface:
4093 case Decl::ObjCIvar:
4095 case Decl::ObjCMethod:
4096 return cast<ObjCMethodDecl>(D)->isInstanceMethod()
4099 case Decl::CXXMethod:
4101 case Decl::CXXConstructor:
4103 case Decl::CXXDestructor:
4105 case Decl::CXXConversion:
4107 case Decl::ObjCProperty:
4109 case Decl::ObjCProtocol:
4115 case Decl::TypeAlias:
4117 case Decl::TypeAliasTemplate:
4121 case Decl::Namespace:
4123 case Decl::NamespaceAlias:
4125 case Decl::TemplateTypeParm:
4127 case Decl::NonTypeTemplateParm:
4129 case Decl::TemplateTemplateParm:
4131 case Decl::FunctionTemplate:
4133 case Decl::ClassTemplate:
4135 case Decl::AccessSpec:
4137 case Decl::ClassTemplatePartialSpecialization:
4139 case Decl::UsingDirective:
4141 case Decl::StaticAssert:
4145 case Decl::TranslationUnit:
4149 case Decl::UnresolvedUsingValue:
4150 case Decl::UnresolvedUsingTypename:
4153 case Decl::UsingEnum:
4156 case Decl::ObjCPropertyImpl:
4157 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
4164 llvm_unreachable(
"Unexpected Kind!");
4169 case Decl::ObjCTypeParam:
4175 case Decl::LinkageSpec:
4179 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
4180 switch (TD->getTagKind()) {
4198 bool LoadExternal,
bool IncludeUndefined,
4199 bool TargetTypeIsPointer =
false) {
4202 Results.EnterNewScope();
4208 if (IncludeUndefined || MD) {
4216 TargetTypeIsPointer)));
4220 Results.ExitScope();
4224 ResultBuilder &Results) {
4227 Results.EnterNewScope();
4231 if (LangOpts.C99 || LangOpts.CPlusPlus11)
4233 Results.ExitScope();
4240 unsigned NumResults) {
4303 llvm_unreachable(
"Invalid ParserCompletionContext!");
4315 ResultBuilder &Results) {
4318 while (isa<BlockDecl>(CurContext))
4321 CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(CurContext);
4328 if (!
P->getDeclName())
4334 Results.getCodeCompletionTUInfo());
4341 S.
Context, CurContext, Overridden->getDeclContext());
4344 llvm::raw_string_ostream OS(Str);
4345 NNS->
print(OS, Policy);
4346 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
4348 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
4351 Builder.AddTypedTextChunk(
4352 Results.getAllocator().CopyString(Overridden->getNameAsString()));
4354 bool FirstParam =
true;
4361 Builder.AddPlaceholderChunk(
4362 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
4368 Results.Ignore(Overridden);
4375 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4376 CodeCompleter->getCodeCompletionTUInfo(),
4378 Results.EnterNewScope();
4387 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
4388 Builder.AddTypedTextChunk(
4389 Builder.getAllocator().CopyString(Modules[I]->Name));
4390 Results.AddResult(
Result(
4395 }
else if (getLangOpts().Modules) {
4403 Builder.AddTypedTextChunk(
4404 Builder.getAllocator().CopyString(Submodule->Name));
4405 Results.AddResult(
Result(
4412 Results.ExitScope();
4414 Results.getCompletionContext(), Results.data(),
4420 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4421 CodeCompleter->getCodeCompletionTUInfo(),
4423 Results.EnterNewScope();
4428 switch (CompletionContext) {
4431 case PCC_ObjCInterface:
4432 case PCC_ObjCImplementation:
4433 case PCC_ObjCInstanceVariableList:
4435 case PCC_MemberTemplate:
4437 case PCC_LocalDeclarationSpecifiers:
4438 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
4442 case PCC_TopLevelOrExpression:
4443 case PCC_ParenthesizedExpression:
4444 case PCC_Expression:
4448 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4450 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4456 case PCC_RecoveryInFunction:
4464 if (!ThisType.isNull())
4465 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
4468 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4470 CodeCompleter->includeGlobals(),
4471 CodeCompleter->loadExternal());
4474 Results.ExitScope();
4476 switch (CompletionContext) {
4477 case PCC_ParenthesizedExpression:
4478 case PCC_Expression:
4480 case PCC_TopLevelOrExpression:
4481 case PCC_RecoveryInFunction:
4482 if (S->getFnParent())
4488 case PCC_ObjCInterface:
4489 case PCC_ObjCImplementation:
4490 case PCC_ObjCInstanceVariableList:
4492 case PCC_MemberTemplate:
4496 case PCC_LocalDeclarationSpecifiers:
4500 if (CodeCompleter->includeMacros())
4504 Results.getCompletionContext(), Results.data(),
4511 bool AtArgumentExpression,
bool IsSuper,
4512 ResultBuilder &Results);
4515 bool AllowNonIdentifiers,
4516 bool AllowNestedNameSpecifiers) {
4518 ResultBuilder Results(
4519 SemaRef, CodeCompleter->getAllocator(),
4520 CodeCompleter->getCodeCompletionTUInfo(),
4521 AllowNestedNameSpecifiers
4526 Results.EnterNewScope();
4529 Results.AddResult(
Result(
"const"));
4530 Results.AddResult(
Result(
"volatile"));
4531 if (getLangOpts().
C99)
4532 Results.AddResult(
Result(
"restrict"));
4538 Results.AddResult(
"final");
4540 if (AllowNonIdentifiers) {
4541 Results.AddResult(
Result(
"operator"));
4545 if (AllowNestedNameSpecifiers) {
4546 Results.allowNestedNameSpecifiers();
4547 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
4548 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4550 Consumer, CodeCompleter->includeGlobals(),
4551 CodeCompleter->loadExternal());
4552 Results.setFilter(
nullptr);
4555 Results.ExitScope();
4561 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
4581 Results.getCompletionContext(), Results.data(),
4586 if (
Scope ==
"clang")
4594 if (
Scope ==
"_Clang")
4596 if (
Scope ==
"__gnu__")
4604 if (Completion == AttributeCompletion::None)
4606 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4607 CodeCompleter->getCodeCompletionTUInfo(),
4620 llvm::StringRef InScopeName;
4621 bool InScopeUnderscore =
false;
4623 InScopeName = InScope->
getName();
4625 InScopeName = NoUnderscore;
4626 InScopeUnderscore =
true;
4635 if (A.IsTargetSpecific &&
4636 !A.existsInTarget(getASTContext().getTargetInfo()))
4638 if (!A.acceptsLangOpts(getLangOpts()))
4640 for (
const auto &S : A.Spellings) {
4641 if (S.Syntax != Syntax)
4643 llvm::StringRef Name = S.NormalizedFullName;
4644 llvm::StringRef
Scope;
4647 std::tie(
Scope, Name) = Name.split(
"::");
4649 std::swap(Name,
Scope);
4653 if (Completion == AttributeCompletion::Scope) {
4655 if (!
Scope.empty() && FoundScopes.insert(
Scope).second) {
4666 if (!InScopeName.empty()) {
4667 if (
Scope != InScopeName)
4672 auto Add = [&](llvm::StringRef
Scope, llvm::StringRef Name,
4675 Results.getCodeCompletionTUInfo());
4677 if (!
Scope.empty()) {
4686 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
Text));
4688 if (!A.ArgNames.empty()) {
4691 for (
const char *Arg : A.ArgNames) {
4695 Builder.AddPlaceholderChunk(Arg);
4700 Results.AddResult(Builder.TakeString());
4707 if (!InScopeUnderscore)
4708 Add(
Scope, Name,
false);
4713 if (!(InScope && !InScopeUnderscore) && SyntaxSupportsGuards) {
4715 if (
Scope.empty()) {
4716 Add(
Scope, Name,
true);
4721 Add(GuardedScope, Name,
true);
4731 for (
const auto &Entry : ParsedAttrInfoRegistry::entries())
4732 AddCompletions(*Entry.instantiate());
4735 Results.getCompletionContext(), Results.data(),
4741 bool IsParenthesized =
false)
4742 : PreferredType(PreferredType), IntegralConstantExpression(
false),
4743 ObjCCollection(
false), IsParenthesized(IsParenthesized) {}
4754struct CoveredEnumerators {
4762 const CoveredEnumerators &Enumerators) {
4764 if (Context.
getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) {
4771 Results.EnterNewScope();
4772 for (
auto *E :
Enum->enumerators()) {
4773 if (Enumerators.Seen.count(E))
4777 Results.AddResult(R, CurContext,
nullptr,
false);
4779 Results.ExitScope();
4785 assert(!
T.isNull());
4808 if (!Results.includeCodePatterns())
4811 Results.getCodeCompletionTUInfo());
4816 if (!Parameters.empty()) {
4825 constexpr llvm::StringLiteral NamePlaceholder =
"!#!NAME_GOES_HERE!#!";
4826 std::string
Type = std::string(NamePlaceholder);
4828 llvm::StringRef Prefix, Suffix;
4829 std::tie(Prefix, Suffix) = llvm::StringRef(
Type).split(NamePlaceholder);
4830 Prefix = Prefix.rtrim();
4831 Suffix = Suffix.ltrim();
4854 ResultBuilder Results(
4855 SemaRef, CodeCompleter->getAllocator(),
4856 CodeCompleter->getCodeCompletionTUInfo(),
4858 Data.IsParenthesized
4861 Data.PreferredType));
4863 Data.IsParenthesized ? PCC_ParenthesizedExpression : PCC_Expression;
4864 if (
Data.ObjCCollection)
4865 Results.setFilter(&ResultBuilder::IsObjCCollection);
4866 else if (
Data.IntegralConstantExpression)
4867 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
4869 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4871 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4873 if (!
Data.PreferredType.isNull())
4874 Results.setPreferredType(
Data.PreferredType.getNonReferenceType());
4877 for (
unsigned I = 0, N =
Data.IgnoreDecls.size(); I != N; ++I)
4878 Results.Ignore(
Data.IgnoreDecls[I]);
4880 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4882 CodeCompleter->includeGlobals(),
4883 CodeCompleter->loadExternal());
4885 Results.EnterNewScope();
4887 Results.ExitScope();
4889 bool PreferredTypeIsPointer =
false;
4890 if (!
Data.PreferredType.isNull()) {
4891 PreferredTypeIsPointer =
Data.PreferredType->isAnyPointerType() ||
4892 Data.PreferredType->isMemberPointerType() ||
4893 Data.PreferredType->isBlockPointerType();
4894 if (
Data.PreferredType->isEnumeralType()) {
4896 if (
auto *Def =
Enum->getDefinition())
4901 CoveredEnumerators());
4905 if (S->getFnParent() && !
Data.ObjCCollection &&
4906 !
Data.IntegralConstantExpression)
4909 if (CodeCompleter->includeMacros())
4911 PreferredTypeIsPointer);
4921 Results.getCompletionContext(), Results.data(),
4927 bool IsParenthesized) {
4928 return CodeCompleteExpression(
4935 CodeCompleteExpression(S, PreferredType);
4936 else if (getLangOpts().
ObjC)
4937 CodeCompleteObjCInstanceMessage(S, E.
get(), std::nullopt,
false);
4954 if (Protocol->hasDefinition())
4955 return Protocol->getDefinition();
4969 Builder.AddResultTypeChunk(
4971 Policy, Builder.getAllocator()));
4977 Builder.AddPlaceholderChunk(
"...");
4979 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
4984 std::string PlaceholderStr =
4987 if (I == N - 1 && BlockProtoLoc &&
4989 PlaceholderStr +=
", ...";
4992 Builder.AddPlaceholderChunk(
4993 Builder.getAllocator().CopyString(PlaceholderStr));
5003 bool AllowNullaryMethods,
DeclContext *CurContext,
5005 bool IsBaseExprStatement =
false,
5006 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
5014 if (!AddedProperties.insert(
P->getIdentifier()).second)
5019 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
5020 !IsBaseExprStatement) {
5022 if (!InOriginalClass)
5024 Results.MaybeAddResult(R, CurContext);
5036 if (!InOriginalClass)
5038 Results.MaybeAddResult(R, CurContext);
5045 Results.getCodeCompletionTUInfo());
5048 BlockLoc, BlockProtoLoc);
5049 Result R =
Result(Builder.TakeString(),
P, Results.getBasePriority(
P));
5050 if (!InOriginalClass)
5052 Results.MaybeAddResult(R, CurContext);
5056 if (!
P->isReadOnly()) {
5058 Results.getCodeCompletionTUInfo());
5062 Builder.AddTypedTextChunk(
5063 Results.getAllocator().CopyString(
P->getName()));
5068 BlockProtoLoc,
true);
5070 Builder.AddPlaceholderChunk(
5071 Builder.getAllocator().CopyString(PlaceholderStr));
5079 Result(Builder.TakeString(),
P,
5080 Results.getBasePriority(
P) +
5084 if (!InOriginalClass)
5086 Results.MaybeAddResult(R, CurContext);
5090 if (IsClassProperty) {
5091 for (
const auto *
P : Container->class_properties())
5094 for (
const auto *
P : Container->instance_properties())
5099 if (AllowNullaryMethods) {
5100 ASTContext &Context = Container->getASTContext();
5104 const IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
5107 if (!AddedProperties.insert(Name).second)
5110 Results.getCodeCompletionTUInfo());
5112 Builder.AddTypedTextChunk(
5113 Results.getAllocator().CopyString(Name->getName()));
5116 if (!InOriginalClass)
5118 Results.MaybeAddResult(R, CurContext);
5121 if (IsClassProperty) {
5122 for (
const auto *M : Container->methods()) {
5126 if (!M->getSelector().isUnarySelector() ||
5127 M->getReturnType()->isVoidType() || M->isInstanceMethod())
5132 for (
auto *M : Container->methods()) {
5133 if (M->getSelector().isUnarySelector())
5141 for (
auto *
P : Protocol->protocols())
5143 CurContext, AddedProperties, Results,
5144 IsBaseExprStatement, IsClassProperty,
5147 dyn_cast<ObjCInterfaceDecl>(Container)) {
5148 if (AllowCategories) {
5150 for (
auto *Cat : IFace->known_categories())
5152 CurContext, AddedProperties, Results,
5153 IsBaseExprStatement, IsClassProperty,
5158 for (
auto *I : IFace->all_referenced_protocols())
5160 CurContext, AddedProperties, Results,
5161 IsBaseExprStatement, IsClassProperty,
5165 if (IFace->getSuperClass())
5167 AllowNullaryMethods, CurContext, AddedProperties,
5168 Results, IsBaseExprStatement, IsClassProperty,
5171 dyn_cast<ObjCCategoryDecl>(Container)) {
5175 CurContext, AddedProperties, Results,
5176 IsBaseExprStatement, IsClassProperty,
5185 std::optional<FixItHint> AccessOpFixIt) {
5188 Results.setObjectTypeQualifiers(BaseType.
getQualifiers(), BaseKind);
5191 Results.allowNestedNameSpecifiers();
5192 std::vector<FixItHint> FixIts;
5194 FixIts.emplace_back(*AccessOpFixIt);
5195 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
5203 if (!Results.empty()) {
5209 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->getParent())
5228 if (
const auto *CTSD =
5229 llvm::dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
5233 RD = CTSD->getSpecializedTemplate()->getTemplatedDecl();
5239 if (
const auto *TD = dyn_cast_or_null<ClassTemplateDecl>(
5240 TST->getTemplateName().getAsTemplateDecl())) {
5241 return TD->getTemplatedDecl();
5285 std::optional<SmallVector<QualType, 1>> ArgTypes;
5287 enum AccessOperator {
5304 std::string AsString;
5306 llvm::raw_string_ostream OS(AsString);
5307 QualType ExactType = deduceType(*ResultType);
5313 B.AddResultTypeChunk(Alloc.
CopyString(AsString));
5316 B.AddTypedTextChunk(Alloc.
CopyString(Name->getName()));
5333 return B.TakeString();
5341 auto *TemplatedEntity = getTemplatedEntity(BaseType.
getDecl(), S);
5342 for (
const Expr *E : constraintsForTemplatedEntity(TemplatedEntity))
5343 believe(E, &BaseType);
5346 std::vector<Member> members() {
5347 std::vector<Member> Results;
5348 for (
const auto &E : this->Results)
5349 Results.push_back(E.second);
5350 llvm::sort(Results, [](
const Member &L,
const Member &R) {
5351 return L.Name->getName() < R.Name->getName();
5361 if (
auto *CSE = dyn_cast<ConceptSpecializationExpr>(E)) {
5375 for (
const auto &Arg : CSE->getTemplateArguments()) {
5376 if (Index >= Params->
size())
5378 if (isApprox(Arg,
T)) {
5379 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Params->
getParam(Index));
5383 auto *TT = cast<TemplateTypeParmType>(TTPD->getTypeForDecl());
5391 }
else if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
5394 if (BO->getOpcode() == BO_LAnd || BO->getOpcode() == BO_LOr) {
5395 believe(BO->getLHS(),
T);
5396 believe(BO->getRHS(),
T);
5398 }
else if (
auto *RE = dyn_cast<RequiresExpr>(E)) {
5401 if (!Req->isDependent())
5405 if (
auto *TR = dyn_cast<concepts::TypeRequirement>(Req)) {
5407 QualType AssertedType = TR->getType()->getType();
5408 ValidVisitor(
this,
T).TraverseType(AssertedType);
5409 }
else if (
auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
5410 ValidVisitor Visitor(
this,
T);
5414 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
5416 ER->getReturnTypeRequirement().getTypeConstraint();
5417 Visitor.OuterExpr = ER->getExpr();
5419 Visitor.TraverseStmt(ER->getExpr());
5420 }
else if (
auto *NR = dyn_cast<concepts::NestedRequirement>(Req)) {
5421 believe(NR->getConstraintExpr(),
T);
5438 Expr *OuterExpr =
nullptr;
5442 : Outer(Outer),
T(
T) {
5450 if (
Base->isPointerType() && IsArrow) {
5452 Base =
Base->getPointeeType().getTypePtr();
5454 if (isApprox(
Base,
T))
5455 addValue(E, E->
getMember(), IsArrow ? Member::Arrow : Member::Dot);
5469 if (Q && isApprox(Q->getAsType(),
T))
5480 if (Q && isApprox(Q->getAsType(),
T))
5498 void addResult(
Member &&M) {
5499 auto R = Outer->Results.try_emplace(M.Name);
5500 Member &O = R.first->second;
5504 std::make_tuple(M.ArgTypes.has_value(), M.ResultType !=
nullptr,
5505 M.Operator) > std::make_tuple(O.ArgTypes.has_value(),
5506 O.ResultType !=
nullptr,
5516 M.Operator = Member::Colons;
5517 addResult(std::move(M));
5521 Member::AccessOperator Operator) {
5522 if (!Name.isIdentifier())
5525 Result.Name = Name.getAsIdentifierInfo();
5526 Result.Operator = Operator;
5529 if (Caller !=
nullptr && Callee == E) {
5530 Result.ArgTypes.emplace();
5531 for (
const auto *Arg : Caller->
arguments())
5532 Result.ArgTypes->push_back(Arg->getType());
5533 if (Caller == OuterExpr) {
5534 Result.ResultType = OuterType;
5538 Result.ResultType = OuterType;
5540 addResult(std::move(Result));
5549 static bool isApprox(
const Type *T1,
const Type *T2) {
5562 Scope *Inner =
nullptr;
5564 if (S->isTemplateParamScope() && S->isDeclScope(D))
5565 return Inner ? Inner->getEntity() :
nullptr;
5581 TD->getAssociatedConstraints(Result);
5583 if (
const auto *CTPSD =
5584 dyn_cast<ClassTemplatePartialSpecializationDecl>(DC))
5585 CTPSD->getAssociatedConstraints(Result);
5586 if (
const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl>(DC))
5587 VTPSD->getAssociatedConstraints(Result);
5598 if (
const auto *Args =
T.getTemplateArgsAsWritten())
5599 if (Args->getNumTemplateArgs() == 1) {
5600 const auto &Arg = Args->arguments().front().getArgument();
5607 llvm::DenseMap<const IdentifierInfo *, Member> Results;
5620 if (!
Unresolved->isSpecificBuiltinType(BuiltinType::Dependent)) {
5622 if (!
Auto || !
Auto->isUndeducedAutoType())
5626 if (
const CallExpr *CE = llvm::dyn_cast<CallExpr>(E)) {
5629 Callee->isSpecificPlaceholderType(BuiltinType::BoundMember))
5635 Callee = FnTypePtr->getPointeeType();
5637 Callee = BPT->getPointeeType();
5640 return FnType->getReturnType().getNonReferenceType();
5643 if (
const auto *OE = llvm::dyn_cast<OverloadExpr>(CE->
getCallee())) {
5647 const Type *Common =
nullptr;
5648 for (
const auto *D : OE->decls()) {
5650 if (
const auto *FD = llvm::dyn_cast<FunctionDecl>(D))
5651 ReturnType = FD->getReturnType();
5652 else if (
const auto *FTD = llvm::dyn_cast<FunctionTemplateDecl>(D))
5653 ReturnType = FTD->getTemplatedDecl()->getReturnType();
5656 const Type *Candidate =
5658 if (Common && Common != Candidate)
5662 if (Common !=
nullptr)
5667 if (
const auto *CDSME = llvm::dyn_cast<CXXDependentScopeMemberExpr>(E)) {
5669 ? CDSME->getBaseType()
5670 : getApproximateType(CDSME->getBase());
5671 if (CDSME->isArrow() && !
Base.isNull())
5677 if (RD && RD->isCompleteDefinition()) {
5679 for (
const auto *
Member : RD->lookupDependentName(
5681 return llvm::isa<ValueDecl>(Member);
5683 return llvm::cast<ValueDecl>(
Member)->getType().getNonReferenceType();
5688 if (
const auto *DRE = llvm::dyn_cast<DeclRefExpr>(E)) {
5689 if (
const auto *VD = llvm::dyn_cast<VarDecl>(DRE->getDecl())) {
5691 return getApproximateType(VD->getInit());
5694 if (
const auto *UO = llvm::dyn_cast<UnaryOperator>(E)) {
5695 if (UO->getOpcode() == UnaryOperatorKind::UO_Deref)
5696 return UO->getSubExpr()->getType()->getPointeeType();
5706 if (
auto *PLE = llvm::dyn_cast_or_null<ParenListExpr>(
Base)) {
5707 if (PLE->getNumExprs() == 0)
5709 Base = PLE->getExpr(PLE->getNumExprs() - 1);
5718 bool IsBaseExprStatement,
QualType PreferredType) {
5720 OtherOpBase = unwrapParenList(OtherOpBase);
5721 if (!
Base || !CodeCompleter)
5728 QualType ConvertedBaseType = getApproximateType(ConvertedBase.
get());
5750 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5751 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
5752 &ResultBuilder::IsMember);
5754 auto DoCompletion = [&](
Expr *
Base,
bool IsArrow,
5755 std::optional<FixItHint> AccessOpFixIt) ->
bool {
5784 RD, std::move(AccessOpFixIt));
5785 }
else if (
const auto *TTPT =
5786 dyn_cast<TemplateTypeParmType>(BaseType.
getTypePtr())) {
5788 IsArrow ? ConceptInfo::Member::Arrow : ConceptInfo::Member::Dot;
5789 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
5790 if (R.Operator != Operator)
5793 R.render(SemaRef, CodeCompleter->getAllocator(),
5794 CodeCompleter->getCodeCompletionTUInfo()));
5796 Result.FixIts.push_back(*AccessOpFixIt);
5797 Results.AddResult(std::move(
Result));
5803 if (AccessOpFixIt) {
5811 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
5814 AddedProperties, Results, IsBaseExprStatement);
5820 SemaRef.
CurContext, AddedProperties, Results,
5821 IsBaseExprStatement,
false,
5828 if (AccessOpFixIt) {
5834 Class = ObjCPtr->getInterfaceDecl();
5840 CodeCompletionDeclConsumer Consumer(Results,
Class, BaseType);
5841 Results.setFilter(&ResultBuilder::IsObjCIvar);
5843 CodeCompleter->includeGlobals(),
5845 CodeCompleter->loadExternal());
5853 Results.EnterNewScope();
5855 bool CompletionSucceded = DoCompletion(
Base, IsArrow, std::nullopt);
5856 if (CodeCompleter->includeFixIts()) {
5859 CompletionSucceded |= DoCompletion(
5860 OtherOpBase, !IsArrow,
5864 Results.ExitScope();
5866 if (!CompletionSucceded)
5871 Results.getCompletionContext(), Results.data(),
5877 bool IsBaseExprStatement) {
5885 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5886 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
5887 &ResultBuilder::IsMember);
5888 Results.EnterNewScope();
5892 AddedProperties, Results, IsBaseExprStatement,
5894 Results.ExitScope();
5896 Results.getCompletionContext(), Results.data(),
5904 ResultBuilder::LookupFilter Filter =
nullptr;
5909 Filter = &ResultBuilder::IsEnum;
5914 Filter = &ResultBuilder::IsUnion;
5921 Filter = &ResultBuilder::IsClassOrStruct;
5926 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
5929 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5930 CodeCompleter->getCodeCompletionTUInfo(), ContextKind);
5931 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
5934 Results.setFilter(Filter);
5936 CodeCompleter->includeGlobals(),
5937 CodeCompleter->loadExternal());
5939 if (CodeCompleter->includeGlobals()) {
5941 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
5943 CodeCompleter->includeGlobals(),
5944 CodeCompleter->loadExternal());
5948 Results.getCompletionContext(), Results.data(),
5955 Results.AddResult(
"const");
5957 Results.AddResult(
"volatile");
5959 Results.AddResult(
"restrict");
5961 Results.AddResult(
"_Atomic");
5963 Results.AddResult(
"__unaligned");
5967 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5968 CodeCompleter->getCodeCompletionTUInfo(),
5970 Results.EnterNewScope();
5972 Results.ExitScope();
5974 Results.getCompletionContext(), Results.data(),
5980 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5981 CodeCompleter->getCodeCompletionTUInfo(),
5983 Results.EnterNewScope();
5986 Results.AddResult(
"noexcept");
5990 Results.AddResult(
"final");
5992 Results.AddResult(
"override");
5995 Results.ExitScope();
5997 Results.getCompletionContext(), Results.data(),
6002 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
6015 if (!
type->isEnumeralType()) {
6017 Data.IntegralConstantExpression =
true;
6018 CodeCompleteExpression(S,
Data);
6032 CoveredEnumerators Enumerators;
6034 SC = SC->getNextSwitchCase()) {
6035 CaseStmt *Case = dyn_cast<CaseStmt>(SC);
6040 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
6041 if (
auto *Enumerator =
6042 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
6049 Enumerators.Seen.insert(Enumerator);
6062 Enumerators.SuggestedQualifier = DRE->getQualifier();
6067 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6068 CodeCompleter->getCodeCompletionTUInfo(),
6073 if (CodeCompleter->includeMacros()) {
6077 Results.getCompletionContext(), Results.data(),
6082 if (Args.size() && !Args.data())
6085 for (
unsigned I = 0; I != Args.size(); ++I)
6106 if (Candidate.Function) {
6107 if (Candidate.Function->isDeleted())
6110 Candidate.Function) &&
6111 Candidate.Function->getNumParams() <= ArgSize &&
6120 if (Candidate.Viable)
6134 for (
auto &Candidate : Candidates) {
6135 QualType CandidateParamType = Candidate.getParamType(N);
6136 if (CandidateParamType.
isNull())
6138 if (ParamType.
isNull()) {
6139 ParamType = CandidateParamType;
6156 if (Candidates.empty())
6160 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc,
6172 Target =
T->getDecl()->getTypeSourceInfo()->getTypeLoc();
6174 }
else if (
const auto *DR = dyn_cast<DeclRefExpr>(Fn)) {
6175 const auto *D = DR->getDecl();
6176 if (
const auto *
const VD = dyn_cast<VarDecl>(D)) {
6177 Target = VD->getTypeSourceInfo()->getTypeLoc();
6179 }
else if (
const auto *ME = dyn_cast<MemberExpr>(Fn)) {
6180 const auto *MD = ME->getMemberDecl();
6181 if (
const auto *FD = dyn_cast<FieldDecl>(MD)) {
6182 Target = FD->getTypeSourceInfo()->getTypeLoc();
6196 Target = A.getModifiedLoc();
6216 Fn = unwrapParenList(Fn);
6217 if (!CodeCompleter || !Fn)
6227 auto ArgsWithoutDependentTypes =
6237 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
6241 }
else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
6243 if (UME->hasExplicitTemplateArgs()) {
6244 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
6245 TemplateArgs = &TemplateArgsBuffer;
6250 1, UME->isImplicitAccess() ?
nullptr : UME->getBase());
6251 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6252 ArgsWithoutDependentTypes.end());
6254 Decls.
append(UME->decls_begin(), UME->decls_end());
6255 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
6259 FirstArgumentIsBase);
6262 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
6263 FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl());
6264 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
6265 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
6273 ArgsWithoutDependentTypes, CandidateSet,
6283 getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
6288 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6289 ArgsWithoutDependentTypes.end());
6307 ArgsWithoutDependentTypes.size(),
6343static std::optional<unsigned>
6346 static constexpr unsigned Invalid = std::numeric_limits<unsigned>::max();
6352 unsigned ArgsAfterDesignator = 0;
6353 for (
const Expr *Arg : Args) {
6354 if (
const auto *DIE = dyn_cast<DesignatedInitExpr>(Arg)) {
6355 if (DIE->size() == 1 && DIE->getDesignator(0)->isFieldDesignator()) {
6356 DesignatedFieldName = DIE->getDesignator(0)->getFieldName();
6357 ArgsAfterDesignator = 0;
6361 }
else if (isa<DesignatedInitUpdateExpr>(Arg)) {
6364 ++ArgsAfterDesignator;
6367 if (!DesignatedFieldName)
6368 return std::nullopt;
6372 unsigned DesignatedIndex = 0;
6373 const FieldDecl *DesignatedField =
nullptr;
6374 for (
const auto *Field :
Aggregate.getAggregate()->fields()) {
6375 if (Field->getIdentifier() == DesignatedFieldName) {
6376 DesignatedField = Field;
6381 if (!DesignatedField)
6385 unsigned AggregateSize =
Aggregate.getNumParams();
6386 while (DesignatedIndex < AggregateSize &&
6387 Aggregate.getParamDecl(DesignatedIndex) != DesignatedField)
6391 return DesignatedIndex + ArgsAfterDesignator + 1;
6414 if (Braced && !RD->
isUnion() &&
6419 if (
auto NextIndex =
6422 if (*NextIndex >= AggregateSize)
6424 Results.push_back(AggregateSig);
6430 if (Args.size() < AggregateSize)
6431 Results.push_back(AggregateSig);
6440 if (
auto *FD = dyn_cast<FunctionDecl>(
C)) {
6443 if (Braced && getLangOpts().
CPlusPlus &&
6451 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
6452 if (Braced && getLangOpts().
CPlusPlus &&
6458 nullptr, Args, CandidateSet,
6479 dyn_cast<CXXConstructorDecl>(ConstructorDecl);
6484 Constructor->getParent(), SS, TemplateTypeTy, II))
6485 return ProduceConstructorSignatureHelp(MemberDecl->getType(),
6486 MemberDecl->getLocation(), ArgExprs,
6487 OpenParLoc, Braced);
6495 if (Index < Params.
size())
6498 Param = Params.
asArray().back();
6504 return llvm::isa<TemplateTypeParmDecl>(Param);
6506 return llvm::isa<NonTypeTemplateParmDecl>(Param);
6508 return llvm::isa<TemplateTemplateParmDecl>(Param);
6510 llvm_unreachable(
"Unhandled switch case");
6516 if (!CodeCompleter || !ParsedTemplate)
6522 bool Matches =
true;
6523 for (
unsigned I = 0; I < Args.size(); ++I) {
6530 Results.emplace_back(TD);
6538 if (
const auto *TD = llvm::dyn_cast<TemplateDecl>(ND))
6551 if (D.isArrayDesignator() || D.isArrayRangeDesignator()) {
6555 assert(D.isFieldDesignator());
6557 if (RD && RD->isCompleteDefinition()) {
6558 for (
const auto *
Member : RD->lookup(D.getFieldDecl()))
6560 NextType = FD->getType();
6565 BaseType = NextType;
6576 if (!RD || RD->fields().empty())
6581 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6582 CodeCompleter->getCodeCompletionTUInfo(), CCC);
6584 Results.EnterNewScope();
6585 for (
const Decl *D : RD->decls()) {
6587 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(D))
6588 FD = IFD->getAnonField();
6589 else if (
auto *DFD = dyn_cast<FieldDecl>(D))
6599 Results.ExitScope();
6601 Results.getCompletionContext(), Results.data(),
6606 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
6608 CodeCompleteOrdinaryName(S, PCC_Expression);
6615 Data.IgnoreDecls.push_back(VD);
6617 CodeCompleteExpression(S,
Data);
6621 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6622 CodeCompleter->getCodeCompletionTUInfo(),
6624 Results.setFilter(&ResultBuilder::IsOrdinaryName);
6625 Results.EnterNewScope();
6627 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6629 CodeCompleter->includeGlobals(),
6630 CodeCompleter->loadExternal());
6636 Results.getCodeCompletionTUInfo());
6638 auto AddElseBodyPattern = [&] {
6643 Builder.AddPlaceholderChunk(
"statements");
6649 Builder.AddPlaceholderChunk(
"statement");
6653 Builder.AddTypedTextChunk(
"else");
6654 if (Results.includeCodePatterns())
6655 AddElseBodyPattern();
6656 Results.AddResult(Builder.TakeString());
6659 Builder.AddTypedTextChunk(
"else if");
6663 Builder.AddPlaceholderChunk(
"condition");
6665 Builder.AddPlaceholderChunk(
"expression");
6667 if (Results.includeCodePatterns()) {
6668 AddElseBodyPattern();
6670 Results.AddResult(Builder.TakeString());
6672 Results.ExitScope();
6674 if (S->getFnParent())
6677 if (CodeCompleter->includeMacros())
6681 Results.getCompletionContext(), Results.data(),
6686 bool EnteringContext,
6687 bool IsUsingDeclaration,
6690 if (SS.
isEmpty() || !CodeCompleter)
6705 ResultBuilder DummyResults(SemaRef, CodeCompleter->getAllocator(),
6706 CodeCompleter->getCodeCompletionTUInfo(), CC);
6707 if (!PreferredType.
isNull())
6708 DummyResults.setPreferredType(PreferredType);
6709 if (S->getEntity()) {
6710 CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
6717 DummyResults.getCompletionContext(),
nullptr, 0);
6732 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6733 CodeCompleter->getCodeCompletionTUInfo(), CC);
6734 if (!PreferredType.
isNull())
6735 Results.setPreferredType(PreferredType);
6736 Results.EnterNewScope();
6741 if (!Results.empty() && NNS && NNS->
isDependent())
6742 Results.AddResult(
"template");
6747 if (
const auto *TTPT =
6748 dyn_cast_or_null<TemplateTypeParmType>(NNS->
getAsType())) {
6749 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
6750 if (R.Operator != ConceptInfo::Member::Colons)
6753 R.render(SemaRef, CodeCompleter->getAllocator(),
6754 CodeCompleter->getCodeCompletionTUInfo())));
6764 if (Ctx && !EnteringContext)
6766 Results.ExitScope();
6769 (CodeCompleter->includeNamespaceLevelDecls() || !Ctx->
isFileContext())) {
6770 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
6774 CodeCompleter->loadExternal());
6778 Results.getCompletionContext(), Results.data(),
6789 Context.setIsUsingDeclaration(
true);
6791 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6792 CodeCompleter->getCodeCompletionTUInfo(), Context,
6793 &ResultBuilder::IsNestedNameSpecifier);
6794 Results.EnterNewScope();
6797 if (!S->isClassScope())
6802 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6804 CodeCompleter->includeGlobals(),
6805 CodeCompleter->loadExternal());
6806 Results.ExitScope();
6809 Results.getCompletionContext(), Results.data(),
6819 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6820 CodeCompleter->getCodeCompletionTUInfo(),
6822 &ResultBuilder::IsNamespaceOrAlias);
6823 Results.EnterNewScope();
6824 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6826 CodeCompleter->includeGlobals(),
6827 CodeCompleter->loadExternal());
6828 Results.ExitScope();
6830 Results.getCompletionContext(), Results.data(),
6839 if (!S->getParent())
6840 Ctx = getASTContext().getTranslationUnitDecl();
6842 bool SuppressedGlobalResults =
6843 Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
6845 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6846 CodeCompleter->getCodeCompletionTUInfo(),
6847 SuppressedGlobalResults
6850 &ResultBuilder::IsNamespace);
6852 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
6857 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
6862 OrigToLatest[NS->getOriginalNamespace()] = *NS;
6866 Results.EnterNewScope();
6867 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
6868 NS = OrigToLatest.begin(),
6869 NSEnd = OrigToLatest.end();
6875 Results.ExitScope();
6879 Results.getCompletionContext(), Results.data(),
6888 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6889 CodeCompleter->getCodeCompletionTUInfo(),
6891 &ResultBuilder::IsNamespaceOrAlias);
6892 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6894 CodeCompleter->includeGlobals(),
6895 CodeCompleter->loadExternal());
6897 Results.getCompletionContext(), Results.data(),
6906 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6907 CodeCompleter->getCodeCompletionTUInfo(),
6909 &ResultBuilder::IsType);
6910 Results.EnterNewScope();
6914#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
6915 if (OO_##Name != OO_Conditional) \
6916 Results.AddResult(Result(Spelling));
6917#include "clang/Basic/OperatorKinds.def"
6920 Results.allowNestedNameSpecifiers();
6921 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6923 CodeCompleter->includeGlobals(),
6924 CodeCompleter->loadExternal());
6928 Results.ExitScope();
6931 Results.getCompletionContext(), Results.data(),
6942 auto *Constructor = dyn_cast<CXXConstructorDecl>(ConstructorD);
6946 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6947 CodeCompleter->getCodeCompletionTUInfo(),
6949 Results.EnterNewScope();
6954 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
6955 if (Initializers[I]->isBaseInitializer())
6956 InitializedBases.insert(getASTContext().getCanonicalType(
6957 QualType(Initializers[I]->getBaseClass(), 0)));
6959 InitializedFields.insert(
6960 cast<FieldDecl>(Initializers[I]->getAnyMember()));
6965 bool SawLastInitializer = Initializers.empty();
6968 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
6970 Results.getCodeCompletionTUInfo());
6971 Builder.AddTypedTextChunk(Name);
6973 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND))
6975 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
6977 FunTemplDecl->getTemplatedDecl(), Builder);
6979 return Builder.TakeString();
6981 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
6984 Results.getCodeCompletionTUInfo());
6985 Builder.AddTypedTextChunk(Name);
6987 Builder.AddPlaceholderChunk(
Type);
6991 Builder.TakeString(), ND,
6993 if (isa<FieldDecl>(ND))
6995 return Results.AddResult(CCR);
6998 Builder.TakeString(),
7002 const char *Name,
const FieldDecl *FD) {
7004 return AddDefaultCtorInit(Name,
7005 FD ? Results.getAllocator().CopyString(
7006 FD->getType().getAsString(Policy))
7010 if (Ctors.begin() == Ctors.end())
7011 return AddDefaultCtorInit(Name, Name, RD);
7015 Results.AddResult(CCR);
7019 const char *BaseName =
7020 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
7021 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
7026 auto AddField = [&](
const FieldDecl *FD) {
7027 const char *FieldName =
7028 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
7029 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
7035 for (
const auto &
Base : ClassDecl->
bases()) {
7036 if (!InitializedBases
7037 .insert(getASTContext().getCanonicalType(
Base.getType()))
7039 SawLastInitializer =
7040 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7041 getASTContext().hasSameUnqualifiedType(
7042 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7047 SawLastInitializer =
false;
7051 for (
const auto &
Base : ClassDecl->
vbases()) {
7052 if (!InitializedBases
7053 .insert(getASTContext().getCanonicalType(
Base.getType()))
7055 SawLastInitializer =
7056 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7057 getASTContext().hasSameUnqualifiedType(
7058 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7063 SawLastInitializer =
false;
7067 for (
auto *Field : ClassDecl->
fields()) {
7068 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
7070 SawLastInitializer = !Initializers.empty() &&
7071 Initializers.back()->isAnyMemberInitializer() &&
7072 Initializers.back()->getAnyMember() == Field;
7076 if (!Field->getDeclName())
7080 SawLastInitializer =
false;
7082 Results.ExitScope();
7085 Results.getCompletionContext(), Results.data(),
7100 bool AfterAmpersand) {
7101 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7102 CodeCompleter->getCodeCompletionTUInfo(),
7104 Results.EnterNewScope();
7108 bool IncludedThis =
false;
7111 IncludedThis =
true;
7120 for (
const auto *D : S->decls()) {
7121 const auto *Var = dyn_cast<VarDecl>(D);
7122 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
7125 if (Known.insert(Var->getIdentifier()).second)
7135 Results.ExitScope();
7138 Results.getCompletionContext(), Results.data(),
7145 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7146 CodeCompleter->getCodeCompletionTUInfo(),
7148 auto ShouldAddDefault = [&D,
this]() {
7160 auto Op =
Id.OperatorFunctionId.Operator;
7163 if (Op == OverloadedOperatorKind::OO_Equal)
7165 if (getLangOpts().CPlusPlus20 &&
7166 (Op == OverloadedOperatorKind::OO_EqualEqual ||
7167 Op == OverloadedOperatorKind::OO_ExclaimEqual ||
7168 Op == OverloadedOperatorKind::OO_Less ||
7169 Op == OverloadedOperatorKind::OO_LessEqual ||
7170 Op == OverloadedOperatorKind::OO_Greater ||
7171 Op == OverloadedOperatorKind::OO_GreaterEqual ||
7172 Op == OverloadedOperatorKind::OO_Spaceship))
7178 Results.EnterNewScope();
7179 if (ShouldAddDefault())
7180 Results.AddResult(
"default");
7183 Results.AddResult(
"delete");
7184 Results.ExitScope();
7186 Results.getCompletionContext(), Results.data(),
7192#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
7195 ResultBuilder &Results,
bool NeedAt) {
7201 Results.getCodeCompletionTUInfo());
7202 if (LangOpts.ObjC) {
7206 Builder.AddPlaceholderChunk(
"property");
7207 Results.AddResult(
Result(Builder.TakeString()));
7212 Builder.AddPlaceholderChunk(
"property");
7213 Results.AddResult(
Result(Builder.TakeString()));
7218 ResultBuilder &Results,
bool NeedAt) {
7224 if (LangOpts.ObjC) {
7239 Results.getCodeCompletionTUInfo());
7244 Builder.AddPlaceholderChunk(
"name");
7245 Results.AddResult(
Result(Builder.TakeString()));
7247 if (Results.includeCodePatterns()) {
7253 Builder.AddPlaceholderChunk(
"class");
7254 Results.AddResult(
Result(Builder.TakeString()));
7259 Builder.AddPlaceholderChunk(
"protocol");
7260 Results.AddResult(
Result(Builder.TakeString()));
7265 Builder.AddPlaceholderChunk(
"class");
7266 Results.AddResult(
Result(Builder.TakeString()));
7270 Builder.AddTypedTextChunk(
7273 Builder.AddPlaceholderChunk(
"alias");
7275 Builder.AddPlaceholderChunk(
"class");
7276 Results.AddResult(
Result(Builder.TakeString()));
7278 if (Results.getSema().getLangOpts().Modules) {
7282 Builder.AddPlaceholderChunk(
"module");
7283 Results.AddResult(
Result(Builder.TakeString()));
7288 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7289 CodeCompleter->getCodeCompletionTUInfo(),
7291 Results.EnterNewScope();
7298 Results.ExitScope();
7300 Results.getCompletionContext(), Results.data(),
7307 Results.getCodeCompletionTUInfo());
7310 const char *EncodeType =
"char[]";
7311 if (Results.getSema().getLangOpts().CPlusPlus ||
7312 Results.getSema().getLangOpts().ConstStrings)
7313 EncodeType =
"const char[]";
7314 Builder.AddResultTypeChunk(EncodeType);
7317 Builder.AddPlaceholderChunk(
"type-name");
7319 Results.AddResult(
Result(Builder.TakeString()));
7322 Builder.AddResultTypeChunk(
"Protocol *");
7325 Builder.AddPlaceholderChunk(
"protocol-name");
7327 Results.AddResult(
Result(Builder.TakeString()));
7330 Builder.AddResultTypeChunk(
"SEL");
7333 Builder.AddPlaceholderChunk(
"selector");
7335 Results.AddResult(
Result(Builder.TakeString()));
7338 Builder.AddResultTypeChunk(
"NSString *");
7340 Builder.AddPlaceholderChunk(
"string");
7341 Builder.AddTextChunk(
"\"");
7342 Results.AddResult(
Result(Builder.TakeString()));
7345 Builder.AddResultTypeChunk(
"NSArray *");
7347 Builder.AddPlaceholderChunk(
"objects, ...");
7349 Results.AddResult(
Result(Builder.TakeString()));
7352 Builder.AddResultTypeChunk(
"NSDictionary *");
7354 Builder.AddPlaceholderChunk(
"key");
7357 Builder.AddPlaceholderChunk(
"object, ...");
7359 Results.AddResult(
Result(Builder.TakeString()));
7362 Builder.AddResultTypeChunk(
"id");
7364 Builder.AddPlaceholderChunk(
"expression");
7366 Results.AddResult(
Result(Builder.TakeString()));
7372 Results.getCodeCompletionTUInfo());
7374 if (Results.includeCodePatterns()) {
7379 Builder.AddPlaceholderChunk(
"statements");
7381 Builder.AddTextChunk(
"@catch");
7383 Builder.AddPlaceholderChunk(
"parameter");
7386 Builder.AddPlaceholderChunk(
"statements");
7388 Builder.AddTextChunk(
"@finally");
7390 Builder.AddPlaceholderChunk(
"statements");
7392 Results.AddResult(
Result(Builder.TakeString()));
7398 Builder.AddPlaceholderChunk(
"expression");
7399 Results.AddResult(
Result(Builder.TakeString()));
7401 if (Results.includeCodePatterns()) {
7406 Builder.AddPlaceholderChunk(
"expression");
7409 Builder.AddPlaceholderChunk(
"statements");
7411 Results.AddResult(
Result(Builder.TakeString()));
7416 ResultBuilder &Results,
bool NeedAt) {
7426 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7427 CodeCompleter->getCodeCompletionTUInfo(),
7429 Results.EnterNewScope();
7431 Results.ExitScope();
7433 Results.getCompletionContext(), Results.data(),
7438 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7439 CodeCompleter->getCodeCompletionTUInfo(),
7441 Results.EnterNewScope();
7444 Results.ExitScope();
7446 Results.getCompletionContext(), Results.data(),
7451 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7452 CodeCompleter->getCodeCompletionTUInfo(),
7454 Results.EnterNewScope();
7456 Results.ExitScope();
7458 Results.getCompletionContext(), Results.data(),
7466 if (Attributes & NewFlag)
7469 Attributes |= NewFlag;
7477 unsigned AssignCopyRetMask =
7483 if (AssignCopyRetMask &&
7502 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7503 CodeCompleter->getCodeCompletionTUInfo(),
7505 Results.EnterNewScope();
7542 Results.getCodeCompletionTUInfo());
7551 Results.getCodeCompletionTUInfo());
7564 Results.ExitScope();
7566 Results.getCompletionContext(), Results.data(),
7580 bool AllowSameLength =
true) {
7581 unsigned NumSelIdents = SelIdents.size();
7594 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
7597 for (
unsigned I = 0; I != NumSelIdents; ++I)
7607 bool AllowSameLength =
true) {
7641 ResultBuilder &Results,
bool InOriginalClass =
true,
7642 bool IsRootClass =
false) {
7646 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
7650 if (M->isInstanceMethod() == WantInstanceMethods ||
7651 (IsRootClass && !WantInstanceMethods)) {
7657 if (!Selectors.insert(M->getSelector()).second)
7660 Result R =
Result(M, Results.getBasePriority(M),
nullptr);
7661 R.StartParameter = SelIdents.size();
7662 R.AllParametersAreInformative = (WantKind !=
MK_Any);
7663 if (!InOriginalClass)
7665 Results.MaybeAddResult(R, CurContext);
7670 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
7671 if (Protocol->hasDefinition()) {
7673 Protocol->getReferencedProtocols();
7675 E = Protocols.
end();
7677 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7678 Selectors, AllowSameLength, Results,
false, IsRootClass);
7687 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7688 Selectors, AllowSameLength, Results,
false, IsRootClass);
7692 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
7693 CurContext, Selectors, AllowSameLength, Results,
7694 InOriginalClass, IsRootClass);
7698 CatDecl->getReferencedProtocols();
7700 E = Protocols.
end();
7702 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7703 Selectors, AllowSameLength, Results,
false, IsRootClass);
7707 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7708 Selectors, AllowSameLength, Results, InOriginalClass,
7716 SelIdents, CurContext, Selectors, AllowSameLength, Results,
7721 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7722 Selectors, AllowSameLength, Results, InOriginalClass,
7729 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7732 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7740 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7741 CodeCompleter->getCodeCompletionTUInfo(),
7743 Results.EnterNewScope();
7749 Results.ExitScope();
7751 Results.getCompletionContext(), Results.data(),
7758 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7761 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7769 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7770 CodeCompleter->getCodeCompletionTUInfo(),
7772 Results.EnterNewScope();
7779 Results.ExitScope();
7781 Results.getCompletionContext(), Results.data(),
7787 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7788 CodeCompleter->getCodeCompletionTUInfo(),
7790 Results.EnterNewScope();
7793 bool AddedInOut =
false;
7796 Results.AddResult(
"in");
7797 Results.AddResult(
"inout");
7802 Results.AddResult(
"out");
7804 Results.AddResult(
"inout");
7809 Results.AddResult(
"bycopy");
7810 Results.AddResult(
"byref");
7811 Results.AddResult(
"oneway");
7814 Results.AddResult(
"nonnull");
7815 Results.AddResult(
"nullable");
7816 Results.AddResult(
"null_unspecified");
7826 Results.getCodeCompletionTUInfo(),
7828 Builder.AddTypedTextChunk(
"IBAction");
7830 Builder.AddPlaceholderChunk(
"selector");
7833 Builder.AddTextChunk(
"id");
7835 Builder.AddTextChunk(
"sender");
7846 Results.ExitScope();
7849 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
7850 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7852 CodeCompleter->includeGlobals(),
7853 CodeCompleter->loadExternal());
7855 if (CodeCompleter->includeMacros())
7859 Results.getCompletionContext(), Results.data(),
7868 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(E);
7886 switch (Msg->getReceiverKind()) {
7890 IFace = ObjType->getInterface();
7894 QualType T = Msg->getInstanceReceiver()->getType();
7896 IFace = Ptr->getInterfaceDecl();
7910 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
7911 .Case(
"retain", IFace)
7912 .Case(
"strong", IFace)
7913 .Case(
"autorelease", IFace)
7914 .Case(
"copy", IFace)
7915 .Case(
"copyWithZone", IFace)
7916 .Case(
"mutableCopy", IFace)
7917 .Case(
"mutableCopyWithZone", IFace)
7918 .Case(
"awakeFromCoder", IFace)
7919 .Case(
"replacementObjectFromCoder", IFace)
7920 .Case(
"class", IFace)
7921 .Case(
"classForCoder", IFace)
7922 .Case(
"superclass", Super)
7925 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
7927 .Case(
"alloc", IFace)
7928 .Case(
"allocWithZone", IFace)
7929 .Case(
"class", IFace)
7930 .Case(
"superclass", Super)
7953 ResultBuilder &Results) {
7964 while ((
Class =
Class->getSuperClass()) && !SuperMethod) {
7971 for (
const auto *Cat :
Class->known_categories()) {
7972 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
7990 CurP != CurPEnd; ++CurP, ++SuperP) {
7993 (*SuperP)->getType()))
7997 if (!(*CurP)->getIdentifier())
8003 Results.getCodeCompletionTUInfo());
8007 Results.getCompletionContext().getBaseType(), Builder);
8010 if (NeedSuperKeyword) {
8011 Builder.AddTypedTextChunk(
"super");
8017 if (NeedSuperKeyword)
8018 Builder.AddTextChunk(
8021 Builder.AddTypedTextChunk(
8025 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
8026 if (I > SelIdents.size())
8029 if (I < SelIdents.size())
8030 Builder.AddInformativeChunk(
8032 else if (NeedSuperKeyword || I > SelIdents.size()) {
8033 Builder.AddTextChunk(
8035 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8036 (*CurP)->getIdentifier()->getName()));
8038 Builder.AddTypedTextChunk(
8040 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8041 (*CurP)->getIdentifier()->getName()));
8053 ResultBuilder Results(
8054 SemaRef, CodeCompleter->getAllocator(),
8055 CodeCompleter->getCodeCompletionTUInfo(),
8058 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
8059 : &ResultBuilder::IsObjCMessageReceiver);
8061 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
8062 Results.EnterNewScope();
8064 CodeCompleter->includeGlobals(),
8065 CodeCompleter->loadExternal());
8071 if (Iface->getSuperClass()) {
8072 Results.AddResult(
Result(
"super"));
8081 Results.ExitScope();
8083 if (CodeCompleter->includeMacros())
8086 Results.getCompletionContext(), Results.data(),
8096 CDecl = CurMethod->getClassInterface();
8105 if (CurMethod->isInstanceMethod()) {
8109 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
8110 AtArgumentExpression, CDecl);
8120 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
8122 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
8124 getASTContext().getTypeDeclType(TD)->getAs<ObjCObjectType>())
8125 CDecl = Iface->getInterface();
8126 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
8138 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
8139 SelIdents, AtArgumentExpression);
8148 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
8149 AtArgumentExpression,
8156 unsigned NumSelIdents) {
8158 ASTContext &Context = Results.getSema().Context;
8162 Result *ResultsData = Results.data();
8163 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
8164 Result &R = ResultsData[I];
8165 if (R.Kind == Result::RK_Declaration &&
8166 isa<ObjCMethodDecl>(R.Declaration)) {
8167 if (R.Priority <= BestPriority) {
8168 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
8169 if (NumSelIdents <= Method->param_size()) {
8171 Method->
parameters()[NumSelIdents - 1]->getType();
8172 if (R.Priority < BestPriority || PreferredType.
isNull()) {
8173 BestPriority = R.Priority;
8174 PreferredType = MyPreferredType;
8184 return PreferredType;
8190 bool AtArgumentExpression,
bool IsSuper,
8191 ResultBuilder &Results) {
8206 Results.EnterNewScope();
8213 Results.Ignore(SuperMethod);
8219 Results.setPreferredSelector(CurMethod->getSelector());
8224 Selectors, AtArgumentExpression, Results);
8231 for (uint32_t I = 0,
8247 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8251 Result R(MethList->getMethod(),
8252 Results.getBasePriority(MethList->getMethod()),
nullptr);
8253 R.StartParameter = SelIdents.size();
8254 R.AllParametersAreInformative =
false;
8255 Results.MaybeAddResult(R, SemaRef.
CurContext);
8260 Results.ExitScope();
8265 bool AtArgumentExpression,
bool IsSuper) {
8269 ResultBuilder Results(
8270 SemaRef, CodeCompleter->getAllocator(),
8271 CodeCompleter->getCodeCompletionTUInfo(),
8276 AtArgumentExpression, IsSuper, Results);
8283 if (AtArgumentExpression) {
8286 if (PreferredType.
isNull())
8287 CodeCompleteOrdinaryName(S, PCC_Expression);
8289 CodeCompleteExpression(S, PreferredType);
8294 Results.getCompletionContext(), Results.data(),
8304 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
8312 RecExpr = Conv.
get();
8326 return CodeCompleteObjCClassMessage(
8328 AtArgumentExpression, Super);
8333 }
else if (RecExpr && getLangOpts().CPlusPlus) {
8336 RecExpr = Conv.
get();
8337 ReceiverType = RecExpr->
getType();
8342 ResultBuilder Results(
8343 SemaRef, CodeCompleter->getAllocator(),
8344 CodeCompleter->getCodeCompletionTUInfo(),
8346 ReceiverType, SelIdents));
8348 Results.EnterNewScope();
8355 Results.Ignore(SuperMethod);
8361 Results.setPreferredSelector(CurMethod->getSelector());
8374 Selectors, AtArgumentExpression, Results);
8381 for (
auto *I : QualID->quals())
8383 AtArgumentExpression, Results);
8390 SemaRef.
CurContext, Selectors, AtArgumentExpression,
8394 for (
auto *I : IFacePtr->quals())
8396 AtArgumentExpression, Results);
8406 for (uint32_t I = 0,
8422 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8426 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
8429 Result R(MethList->getMethod(),
8430 Results.getBasePriority(MethList->getMethod()),
nullptr);
8431 R.StartParameter = SelIdents.size();
8432 R.AllParametersAreInformative =
false;
8433 Results.MaybeAddResult(R, SemaRef.
CurContext);
8437 Results.ExitScope();
8444 if (AtArgumentExpression) {
8447 if (PreferredType.
isNull())
8448 CodeCompleteOrdinaryName(S, PCC_Expression);
8450 CodeCompleteExpression(S, PreferredType);
8455 Results.getCompletionContext(), Results.data(),
8462 Data.ObjCCollection =
true;
8468 Data.IgnoreDecls.push_back(*I);
8472 CodeCompleteExpression(S,
Data);
8480 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
8490 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8491 CodeCompleter->getCodeCompletionTUInfo(),
8493 Results.EnterNewScope();
8504 Results.getCodeCompletionTUInfo());
8506 Builder.AddTypedTextChunk(
8508 Results.AddResult(Builder.TakeString());
8512 std::string Accumulator;
8513 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
8514 if (I == SelIdents.size()) {
8515 if (!Accumulator.empty()) {
8516 Builder.AddInformativeChunk(
8517 Builder.getAllocator().CopyString(Accumulator));
8518 Accumulator.clear();
8525 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
8526 Results.AddResult(Builder.TakeString());
8528 Results.ExitScope();
8531 Results.getCompletionContext(), Results.data(),
8538 bool OnlyForwardDeclarations,
8539 ResultBuilder &Results) {
8542 for (
const auto *D : Ctx->
decls()) {
8544 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
8545 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
8547 Result(Proto, Results.getBasePriority(Proto),
nullptr), CurContext,
8554 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8555 CodeCompleter->getCodeCompletionTUInfo(),
8558 if (CodeCompleter->includeGlobals()) {
8559 Results.EnterNewScope();
8567 Results.Ignore(Protocol);
8573 Results.ExitScope();
8577 Results.getCompletionContext(), Results.data(),
8582 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8583 CodeCompleter->getCodeCompletionTUInfo(),
8586 if (CodeCompleter->includeGlobals()) {
8587 Results.EnterNewScope();
8593 Results.ExitScope();
8597 Results.getCompletionContext(), Results.data(),
8604 bool OnlyForwardDeclarations,
8605 bool OnlyUnimplemented,
8606 ResultBuilder &Results) {
8609 for (
const auto *D : Ctx->
decls()) {
8611 if (
const auto *
Class = dyn_cast<ObjCInterfaceDecl>(D))
8612 if ((!OnlyForwardDeclarations || !
Class->hasDefinition()) &&
8613 (!OnlyUnimplemented || !
Class->getImplementation()))
8621 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8622 CodeCompleter->getCodeCompletionTUInfo(),
8624 Results.EnterNewScope();
8626 if (CodeCompleter->includeGlobals()) {
8632 Results.ExitScope();
8635 Results.getCompletionContext(), Results.data(),
8640 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8641 CodeCompleter->getCodeCompletionTUInfo(),
8643 Results.EnterNewScope();
8645 if (CodeCompleter->includeGlobals()) {
8651 Results.ExitScope();
8654 Results.getCompletionContext(), Results.data(),
8660 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8661 CodeCompleter->getCodeCompletionTUInfo(),
8663 Results.EnterNewScope();
8668 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
8669 Results.Ignore(CurClass);
8671 if (CodeCompleter->includeGlobals()) {
8677 Results.ExitScope();
8680 Results.getCompletionContext(), Results.data(),
8685 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8686 CodeCompleter->getCodeCompletionTUInfo(),
8688 Results.EnterNewScope();
8690 if (CodeCompleter->includeGlobals()) {
8696 Results.ExitScope();
8699 Results.getCompletionContext(), Results.data(),
8707 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8708 CodeCompleter->getCodeCompletionTUInfo(),
8717 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
8718 for (
const auto *Cat :
Class->visible_categories())
8719 CategoryNames.insert(Cat->getIdentifier());
8723 Results.EnterNewScope();
8725 for (
const auto *D : TU->
decls())
8726 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
8727 if (CategoryNames.insert(
Category->getIdentifier()).second)
8731 Results.ExitScope();
8734 Results.getCompletionContext(), Results.data(),
8749 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
8751 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8752 CodeCompleter->getCodeCompletionTUInfo(),
8759 Results.EnterNewScope();
8760 bool IgnoreImplemented =
true;
8762 for (
const auto *Cat :
Class->visible_categories()) {
8763 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
8764 CategoryNames.insert(Cat->getIdentifier()).second)
8765 Results.AddResult(
Result(Cat, Results.getBasePriority(Cat),
nullptr),
8770 IgnoreImplemented =
false;
8772 Results.ExitScope();
8775 Results.getCompletionContext(), Results.data(),
8781 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8782 CodeCompleter->getCodeCompletionTUInfo(), CCContext);
8786 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8787 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8788 !isa<ObjCCategoryImplDecl>(Container)))
8793 for (
const auto *D : Container->decls())
8794 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
8795 Results.Ignore(PropertyImpl->getPropertyDecl());
8799 Results.EnterNewScope();
8801 dyn_cast<ObjCImplementationDecl>(Container))
8804 AddedProperties, Results);
8807 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
8809 AddedProperties, Results);
8810 Results.ExitScope();
8813 Results.getCompletionContext(), Results.data(),
8820 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8821 CodeCompleter->getCodeCompletionTUInfo(),
8826 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8827 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8828 !isa<ObjCCategoryImplDecl>(Container)))
8834 dyn_cast<ObjCImplementationDecl>(Container))
8835 Class = ClassImpl->getClassInterface();
8837 Class = cast<ObjCCategoryImplDecl>(Container)
8839 ->getClassInterface();
8842 QualType PropertyType = getASTContext().getObjCIdType();
8847 Property->getType().getNonReferenceType().getUnqualifiedType();
8850 Results.setPreferredType(PropertyType);
8855 Results.EnterNewScope();
8856 bool SawSimilarlyNamedIvar =
false;
8857 std::string NameWithPrefix;
8858 NameWithPrefix +=
'_';
8859 NameWithPrefix += PropertyName->getName();
8860 std::string NameWithSuffix = PropertyName->getName().str();
8861 NameWithSuffix +=
'_';
8864 Ivar = Ivar->getNextIvar()) {
8865 Results.AddResult(
Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
8870 if ((PropertyName == Ivar->getIdentifier() ||
8871 NameWithPrefix == Ivar->getName() ||
8872 NameWithSuffix == Ivar->getName())) {
8873 SawSimilarlyNamedIvar =
true;
8877 if (Results.size() &&
8878 Results.data()[Results.size() - 1].Kind ==
8880 Results.data()[Results.size() - 1].Declaration == Ivar)
8881 Results.data()[Results.size() - 1].Priority--;
8886 if (!SawSimilarlyNamedIvar) {
8897 PropertyType, getASTContext(), Policy, Allocator));
8898 Builder.AddTypedTextChunk(Allocator.CopyString(NameWithPrefix));
8903 Results.ExitScope();
8906 Results.getCompletionContext(), Results.data(),
8913 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
8922 std::optional<bool> WantInstanceMethods,
8925 bool InOriginalClass =
true) {
8928 if (!IFace->hasDefinition())
8931 IFace = IFace->getDefinition();
8935 IFace->getReferencedProtocols();
8937 E = Protocols.
end();
8940 KnownMethods, InOriginalClass);
8943 for (
auto *Cat : IFace->visible_categories()) {
8945 KnownMethods,
false);
8949 if (IFace->getSuperClass())
8951 WantInstanceMethods, ReturnType, KnownMethods,
8958 Category->getReferencedProtocols();
8960 E = Protocols.
end();
8963 KnownMethods, InOriginalClass);
8966 if (InOriginalClass &&
Category->getClassInterface())
8968 WantInstanceMethods, ReturnType, KnownMethods,
8974 if (!Protocol->hasDefinition())
8976 Protocol = Protocol->getDefinition();
8977 Container = Protocol;
8981 Protocol->getReferencedProtocols();
8983 E = Protocols.
end();
8986 KnownMethods,
false);
8992 for (
auto *M : Container->methods()) {
8993 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
8994 if (!ReturnType.
isNull() &&
8998 KnownMethods[M->getSelector()] =
8999 KnownMethodsMap::mapped_type(M, InOriginalClass);
9013 Builder.AddTextChunk(Builder.getAllocator().CopyString(Quals));
9014 Builder.AddTextChunk(
9025 if (
Class->getIdentifier() &&
Class->getIdentifier()->getName() == Name)
9034 bool IsInstanceMethod,
9037 ResultBuilder &Results) {
9039 if (!PropName || PropName->
getLength() == 0)
9057 const char *CopiedKey;
9060 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
9062 operator const char *() {
9066 return CopiedKey = Allocator.CopyString(Key);
9068 } Key(Allocator, PropName->
getName());
9071 std::string UpperKey = std::string(PropName->
getName());
9072 if (!UpperKey.empty())
9075 bool ReturnTypeMatchesProperty =
9079 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
9082 if (IsInstanceMethod &&
9084 ReturnTypeMatchesProperty && !
Property->getGetterMethodDecl()) {
9089 Builder.AddTypedTextChunk(Key);
9096 if (IsInstanceMethod &&
9097 ((!ReturnType.
isNull() &&
9100 Property->getType()->isBooleanType())))) {
9101 std::string SelectorName = (Twine(
"is") + UpperKey).str();
9105 if (ReturnType.
isNull()) {
9107 Builder.AddTextChunk(
"BOOL");
9111 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9118 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
9119 !
Property->getSetterMethodDecl()) {
9120 std::string SelectorName = (Twine(
"set") + UpperKey).str();
9122 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9123 if (ReturnType.
isNull()) {
9125 Builder.AddTextChunk(
"void");
9129 Builder.AddTypedTextChunk(
9130 Allocator.CopyString(SelectorId->
getName() +
":"));
9133 Builder.AddTextChunk(Key);
9144 if (
const auto *ObjCPointer =
9169 if (IsInstanceMethod &&
9171 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
9175 if (ReturnType.
isNull()) {
9177 Builder.AddTextChunk(
"NSUInteger");
9181 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9183 Result(Builder.TakeString(),
9184 std::min(IndexedGetterPriority, UnorderedGetterPriority),
9191 if (IsInstanceMethod &&
9193 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
9195 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9196 if (ReturnType.
isNull()) {
9198 Builder.AddTextChunk(
"id");
9202 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9204 Builder.AddTextChunk(
"NSUInteger");
9206 Builder.AddTextChunk(
"index");
9207 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9213 if (IsInstanceMethod &&
9220 std::string SelectorName = (Twine(
Property->getName()) +
"AtIndexes").str();
9222 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9223 if (ReturnType.
isNull()) {
9225 Builder.AddTextChunk(
"NSArray *");
9229 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9231 Builder.AddTextChunk(
"NSIndexSet *");
9233 Builder.AddTextChunk(
"indexes");
9234 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9240 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9241 std::string SelectorName = (Twine(
"get") + UpperKey).str();
9245 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9246 if (ReturnType.
isNull()) {
9248 Builder.AddTextChunk(
"void");
9252 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9254 Builder.AddPlaceholderChunk(
"object-type");
9255 Builder.AddTextChunk(
" **");
9257 Builder.AddTextChunk(
"buffer");
9259 Builder.AddTypedTextChunk(
"range:");
9261 Builder.AddTextChunk(
"NSRange");
9263 Builder.AddTextChunk(
"inRange");
9264 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9272 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9273 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
9277 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9278 if (ReturnType.
isNull()) {
9280 Builder.AddTextChunk(
"void");
9284 Builder.AddTypedTextChunk(
"insertObject:");
9286 Builder.AddPlaceholderChunk(
"object-type");
9287 Builder.AddTextChunk(
" *");
9289 Builder.AddTextChunk(
"object");
9291 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9293 Builder.AddPlaceholderChunk(
"NSUInteger");
9295 Builder.AddTextChunk(
"index");
9296 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9302 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9303 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
9307 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9308 if (ReturnType.
isNull()) {
9310 Builder.AddTextChunk(
"void");
9314 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9316 Builder.AddTextChunk(
"NSArray *");
9318 Builder.AddTextChunk(
"array");
9320 Builder.AddTypedTextChunk(
"atIndexes:");
9322 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9324 Builder.AddTextChunk(
"indexes");
9325 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9331 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9332 std::string SelectorName =
9333 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
9335 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9336 if (ReturnType.
isNull()) {
9338 Builder.AddTextChunk(
"void");
9342 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9344 Builder.AddTextChunk(
"NSUInteger");
9346 Builder.AddTextChunk(
"index");
9347 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9353 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9354 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
9356 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9357 if (ReturnType.
isNull()) {
9359 Builder.AddTextChunk(
"void");
9363 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9365 Builder.AddTextChunk(
"NSIndexSet *");
9367 Builder.AddTextChunk(
"indexes");
9368 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9374 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9375 std::string SelectorName =
9376 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
9380 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9381 if (ReturnType.
isNull()) {
9383 Builder.AddTextChunk(
"void");
9387 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9389 Builder.AddPlaceholderChunk(
"NSUInteger");
9391 Builder.AddTextChunk(
"index");
9393 Builder.AddTypedTextChunk(
"withObject:");
9395 Builder.AddTextChunk(
"id");
9397 Builder.AddTextChunk(
"object");
9398 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9404 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9405 std::string SelectorName1 =
9406 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
9407 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
9411 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9412 if (ReturnType.
isNull()) {
9414 Builder.AddTextChunk(
"void");
9418 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName1 +
":"));
9420 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9422 Builder.AddTextChunk(
"indexes");
9424 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName2 +
":"));
9426 Builder.AddTextChunk(
"NSArray *");
9428 Builder.AddTextChunk(
"array");
9429 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9436 if (IsInstanceMethod &&
9442 ->
getName() ==
"NSEnumerator"))) {
9443 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
9447 if (ReturnType.
isNull()) {
9449 Builder.AddTextChunk(
"NSEnumerator *");
9453 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9454 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9460 if (IsInstanceMethod &&
9462 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
9464 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9465 if (ReturnType.
isNull()) {
9467 Builder.AddPlaceholderChunk(
"object-type");
9468 Builder.AddTextChunk(
" *");
9472 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9474 if (ReturnType.
isNull()) {
9475 Builder.AddPlaceholderChunk(
"object-type");
9476 Builder.AddTextChunk(
" *");
9479 ReturnType, Context, Policy, Builder.getAllocator()));
9482 Builder.AddTextChunk(
"object");
9483 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9490 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9491 std::string SelectorName =
9492 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
9494 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9495 if (ReturnType.
isNull()) {
9497 Builder.AddTextChunk(
"void");
9501 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9503 Builder.AddPlaceholderChunk(
"object-type");
9504 Builder.AddTextChunk(
" *");
9506 Builder.AddTextChunk(
"object");
9507 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9513 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9514 std::string SelectorName = (Twine(
"add") + UpperKey).str();
9516 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9517 if (ReturnType.
isNull()) {
9519 Builder.AddTextChunk(
"void");
9523 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9525 Builder.AddTextChunk(
"NSSet *");
9527 Builder.AddTextChunk(
"objects");
9528 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9534 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9535 std::string SelectorName =
9536 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
9538 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9539 if (ReturnType.
isNull()) {
9541 Builder.AddTextChunk(
"void");
9545 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9547 Builder.AddPlaceholderChunk(
"object-type");
9548 Builder.AddTextChunk(
" *");
9550 Builder.AddTextChunk(
"object");
9551 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9557 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9558 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
9560 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9561 if (ReturnType.
isNull()) {
9563 Builder.AddTextChunk(
"void");
9567 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9569 Builder.AddTextChunk(
"NSSet *");
9571 Builder.AddTextChunk(
"objects");
9572 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9578 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9579 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
9581 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9582 if (ReturnType.
isNull()) {
9584 Builder.AddTextChunk(
"void");
9588 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9590 Builder.AddTextChunk(
"NSSet *");
9592 Builder.AddTextChunk(
"objects");
9593 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9600 if (!IsInstanceMethod &&
9607 std::string SelectorName =
9608 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
9612 if (ReturnType.
isNull()) {
9614 Builder.AddTextChunk(
"NSSet<NSString *> *");
9618 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9625 if (!IsInstanceMethod &&
9628 std::string SelectorName =
9629 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
9633 if (ReturnType.
isNull()) {
9635 Builder.AddTextChunk(
"BOOL");
9639 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9647 Scope *S, std::optional<bool> IsInstanceMethod,
ParsedType ReturnTy) {
9652 Decl *IDecl =
nullptr;
9659 bool IsInImplementation =
false;
9660 if (
Decl *D = IDecl) {
9662 SearchDecl = Impl->getClassInterface();
9663 IsInImplementation =
true;
9665 dyn_cast<ObjCCategoryImplDecl>(D)) {
9666 SearchDecl = CatImpl->getCategoryDecl();
9667 IsInImplementation =
true;
9669 SearchDecl = dyn_cast<ObjCContainerDecl>(D);
9672 if (!SearchDecl && S) {
9674 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
9690 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9691 CodeCompleter->getCodeCompletionTUInfo(),
9693 Results.EnterNewScope();
9695 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9696 MEnd = KnownMethods.end();
9700 Results.getCodeCompletionTUInfo());
9703 if (!IsInstanceMethod) {
9710 if (ReturnType.
isNull()) {
9721 Builder.AddTypedTextChunk(
9728 P != PEnd; (
void)++
P, ++I) {
9731 Builder.AddTypedTextChunk(
9735 Builder.AddTypedTextChunk(
9743 ParamType = (*P)->getType();
9745 ParamType = (*P)->getOriginalType();
9750 Context, Policy, Builder);
9753 Builder.AddTextChunk(
9754 Builder.getAllocator().CopyString(
Id->getName()));
9761 Builder.AddTextChunk(
"...");
9764 if (IsInImplementation && Results.includeCodePatterns()) {
9771 Builder.AddTextChunk(
"return");
9773 Builder.AddPlaceholderChunk(
"expression");
9776 Builder.AddPlaceholderChunk(
"statements");
9784 if (!M->second.getInt())
9786 Results.AddResult(std::move(R));
9793 Containers.push_back(SearchDecl);
9796 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9797 MEnd = KnownMethods.end();
9799 KnownSelectors.insert(M->first);
9804 IFace =
Category->getClassInterface();
9809 if (IsInstanceMethod) {
9810 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
9811 for (
auto *
P : Containers[I]->instance_properties())
9813 KnownSelectors, Results);
9817 Results.ExitScope();
9820 Results.getCompletionContext(), Results.data(),
9825 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
9830 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
9842 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9843 CodeCompleter->getCodeCompletionTUInfo(),
9847 Results.setPreferredType(
9850 Results.EnterNewScope();
9855 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
9856 : &M->second.second;
9857 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
9861 if (AtParameterName) {
9863 unsigned NumSelIdents = SelIdents.size();
9865 NumSelIdents <= MethList->getMethod()->param_size()) {
9867 MethList->getMethod()->parameters()[NumSelIdents - 1];
9870 Results.getCodeCompletionTUInfo());
9871 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
9873 Results.AddResult(Builder.TakeString());
9880 Result R(MethList->getMethod(),
9881 Results.getBasePriority(MethList->getMethod()),
nullptr);
9882 R.StartParameter = SelIdents.size();
9883 R.AllParametersAreInformative =
false;
9884 R.DeclaringEntity =
true;
9885 Results.MaybeAddResult(R, SemaRef.
CurContext);
9889 Results.ExitScope();
9891 if (!AtParameterName && !SelIdents.empty() &&
9892 SelIdents.front()->getName().starts_with(
"init")) {
9893 for (
const auto &M : SemaRef.
PP.
macros()) {
9894 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
9896 Results.EnterNewScope();
9898 Results.getCodeCompletionTUInfo());
9899 Builder.AddTypedTextChunk(
9900 Builder.getAllocator().CopyString(M.first->getName()));
9903 Results.ExitScope();
9908 Results.getCompletionContext(), Results.data(),
9913 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9914 CodeCompleter->getCodeCompletionTUInfo(),
9916 Results.EnterNewScope();
9920 Results.getCodeCompletionTUInfo());
9921 Builder.AddTypedTextChunk(
"if");
9923 Builder.AddPlaceholderChunk(
"condition");
9924 Results.AddResult(Builder.TakeString());
9927 Builder.AddTypedTextChunk(
"ifdef");
9929 Builder.AddPlaceholderChunk(
"macro");
9930 Results.AddResult(Builder.TakeString());
9933 Builder.AddTypedTextChunk(
"ifndef");
9935 Builder.AddPlaceholderChunk(
"macro");
9936 Results.AddResult(Builder.TakeString());
9938 if (InConditional) {
9940 Builder.AddTypedTextChunk(
"elif");
9942 Builder.AddPlaceholderChunk(
"condition");
9943 Results.AddResult(Builder.TakeString());
9946 Builder.AddTypedTextChunk(
"elifdef");
9948 Builder.AddPlaceholderChunk(
"macro");
9949 Results.AddResult(Builder.TakeString());
9952 Builder.AddTypedTextChunk(
"elifndef");
9954 Builder.AddPlaceholderChunk(
"macro");
9955 Results.AddResult(Builder.TakeString());
9958 Builder.AddTypedTextChunk(
"else");
9959 Results.AddResult(Builder.TakeString());
9962 Builder.AddTypedTextChunk(
"endif");
9963 Results.AddResult(Builder.TakeString());
9967 Builder.AddTypedTextChunk(
"include");
9969 Builder.AddTextChunk(
"\"");
9970 Builder.AddPlaceholderChunk(
"header");
9971 Builder.AddTextChunk(
"\"");
9972 Results.AddResult(Builder.TakeString());
9975 Builder.AddTypedTextChunk(
"include");
9977 Builder.AddTextChunk(
"<");
9978 Builder.AddPlaceholderChunk(
"header");
9979 Builder.AddTextChunk(
">");
9980 Results.AddResult(Builder.TakeString());
9983 Builder.AddTypedTextChunk(
"define");
9985 Builder.AddPlaceholderChunk(
"macro");
9986 Results.AddResult(Builder.TakeString());
9989 Builder.AddTypedTextChunk(
"define");
9991 Builder.AddPlaceholderChunk(
"macro");
9993 Builder.AddPlaceholderChunk(
"args");
9995 Results.AddResult(Builder.TakeString());
9998 Builder.AddTypedTextChunk(
"undef");
10000 Builder.AddPlaceholderChunk(
"macro");
10001 Results.AddResult(Builder.TakeString());
10004 Builder.AddTypedTextChunk(
"line");
10006 Builder.AddPlaceholderChunk(
"number");
10007 Results.AddResult(Builder.TakeString());
10010 Builder.AddTypedTextChunk(
"line");
10012 Builder.AddPlaceholderChunk(
"number");
10014 Builder.AddTextChunk(
"\"");
10015 Builder.AddPlaceholderChunk(
"filename");
10016 Builder.AddTextChunk(
"\"");
10017 Results.AddResult(Builder.TakeString());
10020 Builder.AddTypedTextChunk(
"error");
10022 Builder.AddPlaceholderChunk(
"message");
10023 Results.AddResult(Builder.TakeString());
10026 Builder.AddTypedTextChunk(
"pragma");
10028 Builder.AddPlaceholderChunk(
"arguments");
10029 Results.AddResult(Builder.TakeString());
10031 if (getLangOpts().
ObjC) {
10033 Builder.AddTypedTextChunk(
"import");
10035 Builder.AddTextChunk(
"\"");
10036 Builder.AddPlaceholderChunk(
"header");
10037 Builder.AddTextChunk(
"\"");
10038 Results.AddResult(Builder.TakeString());
10041 Builder.AddTypedTextChunk(
"import");
10043 Builder.AddTextChunk(
"<");
10044 Builder.AddPlaceholderChunk(
"header");
10045 Builder.AddTextChunk(
">");
10046 Results.AddResult(Builder.TakeString());
10050 Builder.AddTypedTextChunk(
"include_next");
10052 Builder.AddTextChunk(
"\"");
10053 Builder.AddPlaceholderChunk(
"header");
10054 Builder.AddTextChunk(
"\"");
10055 Results.AddResult(Builder.TakeString());
10058 Builder.AddTypedTextChunk(
"include_next");
10060 Builder.AddTextChunk(
"<");
10061 Builder.AddPlaceholderChunk(
"header");
10062 Builder.AddTextChunk(
">");
10063 Results.AddResult(Builder.TakeString());
10066 Builder.AddTypedTextChunk(
"warning");
10068 Builder.AddPlaceholderChunk(
"message");
10069 Results.AddResult(Builder.TakeString());
10076 Results.ExitScope();
10079 Results.getCompletionContext(), Results.data(),
10085 CodeCompleteOrdinaryName(S, S->getFnParent()
10091 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10092 CodeCompleter->getCodeCompletionTUInfo(),
10095 if (!IsDefinition && CodeCompleter->includeMacros()) {
10098 Results.getCodeCompletionTUInfo());
10099 Results.EnterNewScope();
10103 Builder.AddTypedTextChunk(
10104 Builder.getAllocator().CopyString(M->first->getName()));
10108 Results.ExitScope();
10109 }
else if (IsDefinition) {
10114 Results.getCompletionContext(), Results.data(),
10119 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10120 CodeCompleter->getCodeCompletionTUInfo(),
10123 if (CodeCompleter->includeMacros())
10127 Results.EnterNewScope();
10129 Results.getCodeCompletionTUInfo());
10130 Builder.AddTypedTextChunk(
"defined");
10133 Builder.AddPlaceholderChunk(
"macro");
10135 Results.AddResult(Builder.TakeString());
10136 Results.ExitScope();
10139 Results.getCompletionContext(), Results.data(),
10159 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
10162 llvm::sys::path::native(NativeRelDir);
10163 llvm::vfs::FileSystem &FS =
10166 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10167 CodeCompleter->getCodeCompletionTUInfo(),
10172 auto AddCompletion = [&](StringRef
Filename,
bool IsDirectory) {
10175 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
10176 auto R = SeenResults.insert(TypedChunk);
10178 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
10179 *R.first = InternedTyped;
10181 CodeCompleter->getCodeCompletionTUInfo());
10182 Builder.AddTypedTextChunk(InternedTyped);
10190 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
10194 if (!NativeRelDir.empty()) {
10198 auto Begin = llvm::sys::path::begin(NativeRelDir);
10199 auto End = llvm::sys::path::end(NativeRelDir);
10201 llvm::sys::path::append(Dir, *
Begin +
".framework",
"Headers");
10202 llvm::sys::path::append(Dir, ++
Begin, End);
10204 llvm::sys::path::append(Dir, NativeRelDir);
10208 const StringRef &Dirname = llvm::sys::path::filename(Dir);
10209 const bool isQt = Dirname.starts_with(
"Qt") || Dirname ==
"ActiveQt";
10210 const bool ExtensionlessHeaders =
10211 IsSystem || isQt || Dir.ends_with(
".framework/Headers");
10212 std::error_code EC;
10213 unsigned Count = 0;
10214 for (
auto It = FS.dir_begin(Dir, EC);
10215 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
10216 if (++Count == 2500)
10218 StringRef
Filename = llvm::sys::path::filename(It->path());
10223 llvm::sys::fs::file_type
Type = It->type();
10224 if (
Type == llvm::sys::fs::file_type::symlink_file) {
10225 if (
auto FileStatus = FS.status(It->path()))
10226 Type = FileStatus->getType();
10229 case llvm::sys::fs::file_type::directory_file:
10233 NativeRelDir.empty() && !
Filename.consume_back(
".framework"))
10238 case llvm::sys::fs::file_type::regular_file: {
10240 const bool IsHeader =
Filename.ends_with_insensitive(
".h") ||
10241 Filename.ends_with_insensitive(
".hh") ||
10242 Filename.ends_with_insensitive(
".hpp") ||
10243 Filename.ends_with_insensitive(
".hxx") ||
10244 Filename.ends_with_insensitive(
".inc") ||
10245 (ExtensionlessHeaders && !
Filename.contains(
'.'));
10260 switch (IncludeDir.getLookupType()) {
10265 AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
10269 AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
10279 using llvm::make_range;
10283 AddFilesFromIncludeDir(CurFile->getDir().getName(),
false,
10285 for (
const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
10286 AddFilesFromDirLookup(D,
false);
10288 for (
const auto &D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
10289 AddFilesFromDirLookup(D,
false);
10290 for (
const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
10291 AddFilesFromDirLookup(D,
true);
10294 Results.getCompletionContext(), Results.data(),
10305 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10306 CodeCompleter->getCodeCompletionTUInfo(),
10308 Results.EnterNewScope();
10309 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
10313 Twine(Platform) +
"ApplicationExtension")));
10315 Results.ExitScope();
10317 Results.getCompletionContext(), Results.data(),
10324 ResultBuilder Builder(SemaRef, Allocator, CCTUInfo,
10326 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
10327 CodeCompletionDeclConsumer Consumer(
10328 Builder, getASTContext().getTranslationUnitDecl());
10331 !CodeCompleter || CodeCompleter->loadExternal());
10334 if (!CodeCompleter || CodeCompleter->includeMacros())
10336 !CodeCompleter || CodeCompleter->loadExternal(),
true);
10339 Results.insert(Results.end(), Builder.data(),
10340 Builder.data() + Builder.size());
10345 :
SemaBase(S), CodeCompleter(CompletionConsumer) {}
This file provides AST data structures related to concepts.
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
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 OverloadCompare compareOverloads(const CXXMethodDecl &Candidate, const CXXMethodDecl &Incumbent, const Qualifiers &ObjectQuals, ExprValueKind ObjectKind)
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 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::@1262::AnnotatingParser::Context::@343 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...
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
QualType getBaseType() const
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
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 isFileContext() const
bool isObjCContainer() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
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.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
DeclaratorContext getContext() const
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isStaticMember()
Returns true if this declares a static member.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
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 type named by the typename specifier as an identifier.
A qualified reference to a name whose declaration cannot yet be resolved.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
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 ...
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...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
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.
llvm::iterator_range< submodule_iterator > submodules()
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
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...
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Recursively visit a C++ nested-name-specifier with location information.
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)
llvm::DenseMap< Selector, Lists >::iterator iterator
int count(Selector Sel) const
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...
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.
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=std::nullopt, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
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)
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() 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 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...
@ 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....
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.
@ 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.
@ 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.
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_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.
@ 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)
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
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.