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();
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;
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) {
1815 Results.getCodeCompletionTUInfo());
1816 if (LangOpts.CPlusPlus) {
1824 Builder.AddTypedTextChunk(
"typename");
1826 Builder.AddPlaceholderChunk(
"name");
1827 Results.AddResult(
Result(Builder.TakeString()));
1829 if (LangOpts.CPlusPlus11) {
1834 Builder.AddTypedTextChunk(
"decltype");
1836 Builder.AddPlaceholderChunk(
"expression");
1838 Results.AddResult(
Result(Builder.TakeString()));
1844 if (LangOpts.GNUKeywords) {
1850 Builder.AddTypedTextChunk(
"typeof");
1852 Builder.AddPlaceholderChunk(
"expression");
1853 Results.AddResult(
Result(Builder.TakeString()));
1855 Builder.AddTypedTextChunk(
"typeof");
1857 Builder.AddPlaceholderChunk(
"type");
1859 Results.AddResult(
Result(Builder.TakeString()));
1870 const LangOptions &LangOpts, ResultBuilder &Results) {
1875 Results.AddResult(
Result(
"extern"));
1876 Results.AddResult(
Result(
"static"));
1878 if (LangOpts.CPlusPlus11) {
1883 Builder.AddTypedTextChunk(
"alignas");
1885 Builder.AddPlaceholderChunk(
"expression");
1887 Results.AddResult(
Result(Builder.TakeString()));
1889 Results.AddResult(
Result(
"constexpr"));
1890 Results.AddResult(
Result(
"thread_local"));
1896 const LangOptions &LangOpts, ResultBuilder &Results) {
1901 if (LangOpts.CPlusPlus) {
1902 Results.AddResult(
Result(
"explicit"));
1903 Results.AddResult(
Result(
"friend"));
1904 Results.AddResult(
Result(
"mutable"));
1905 Results.AddResult(
Result(
"virtual"));
1913 if (LangOpts.CPlusPlus || LangOpts.C99)
1914 Results.AddResult(
Result(
"inline"));
1934 ResultBuilder &Results,
bool NeedAt);
1936 ResultBuilder &Results,
bool NeedAt);
1938 ResultBuilder &Results,
bool NeedAt);
1943 Results.getCodeCompletionTUInfo());
1944 Builder.AddTypedTextChunk(
"typedef");
1946 Builder.AddPlaceholderChunk(
"type");
1948 Builder.AddPlaceholderChunk(
"name");
1955 ResultBuilder &Results) {
1956 Builder.AddTypedTextChunk(
"using");
1958 Builder.AddPlaceholderChunk(
"name");
1960 Builder.AddPlaceholderChunk(
"type");
1983 return LangOpts.CPlusPlus;
1990 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
1993 llvm_unreachable(
"Invalid ParserCompletionContext!");
2020 if (!
T.getLocalQualifiers()) {
2023 return BT->getNameAsCString(Policy);
2026 if (
const TagType *TagT = dyn_cast<TagType>(
T))
2027 if (
TagDecl *Tag = TagT->getDecl())
2028 if (!Tag->hasNameForLinkage()) {
2029 switch (Tag->getTagKind()) {
2031 return "struct <anonymous>";
2033 return "__interface <anonymous>";
2035 return "class <anonymous>";
2037 return "union <anonymous>";
2039 return "enum <anonymous>";
2046 T.getAsStringInternal(
Result, Policy);
2047 return Allocator.CopyString(
Result);
2059 Builder.AddResultTypeChunk(
2061 Builder.AddTypedTextChunk(
"this");
2066 ResultBuilder &Results,
2068 if (!LangOpts.CPlusPlus11)
2071 Builder.AddTypedTextChunk(
"static_assert");
2073 Builder.AddPlaceholderChunk(
"expression");
2075 Builder.AddPlaceholderChunk(
"message");
2084 Sema &S = Results.getSema();
2085 const auto *CR = llvm::dyn_cast<CXXRecordDecl>(S.
CurContext);
2091 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
2092 for (
auto *Method : CR->methods()) {
2095 Overrides[Method->
getName()].push_back(Method);
2098 for (
const auto &
Base : CR->bases()) {
2099 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
2102 for (
auto *Method : BR->methods()) {
2105 const auto it = Overrides.find(Method->
getName());
2106 bool IsOverriden =
false;
2107 if (it != Overrides.end()) {
2108 for (
auto *MD : it->second) {
2126 false, CCContext, Policy);
2136 Scope *S,
Sema &SemaRef, ResultBuilder &Results) {
2144 if (Results.includeCodePatterns()) {
2146 Builder.AddTypedTextChunk(
"namespace");
2148 Builder.AddPlaceholderChunk(
"identifier");
2152 Builder.AddPlaceholderChunk(
"declarations");
2155 Results.AddResult(
Result(Builder.TakeString()));
2159 Builder.AddTypedTextChunk(
"namespace");
2161 Builder.AddPlaceholderChunk(
"name");
2163 Builder.AddPlaceholderChunk(
"namespace");
2165 Results.AddResult(
Result(Builder.TakeString()));
2168 Builder.AddTypedTextChunk(
"using namespace");
2170 Builder.AddPlaceholderChunk(
"identifier");
2172 Results.AddResult(
Result(Builder.TakeString()));
2175 Builder.AddTypedTextChunk(
"asm");
2177 Builder.AddPlaceholderChunk(
"string-literal");
2179 Results.AddResult(
Result(Builder.TakeString()));
2181 if (Results.includeCodePatterns()) {
2183 Builder.AddTypedTextChunk(
"template");
2185 Builder.AddPlaceholderChunk(
"declaration");
2186 Results.AddResult(
Result(Builder.TakeString()));
2201 Builder.AddTypedTextChunk(
"using");
2203 Builder.AddPlaceholderChunk(
"qualifier");
2204 Builder.AddTextChunk(
"::");
2205 Builder.AddPlaceholderChunk(
"name");
2207 Results.AddResult(
Result(Builder.TakeString()));
2214 Builder.AddTypedTextChunk(
"using typename");
2216 Builder.AddPlaceholderChunk(
"qualifier");
2217 Builder.AddTextChunk(
"::");
2218 Builder.AddPlaceholderChunk(
"name");
2220 Results.AddResult(
Result(Builder.TakeString()));
2228 bool IsNotInheritanceScope = !S->isClassInheritanceScope();
2230 Builder.AddTypedTextChunk(
"public");
2231 if (IsNotInheritanceScope && Results.includeCodePatterns())
2233 Results.AddResult(
Result(Builder.TakeString()));
2236 Builder.AddTypedTextChunk(
"protected");
2237 if (IsNotInheritanceScope && Results.includeCodePatterns())
2239 Results.AddResult(
Result(Builder.TakeString()));
2242 Builder.AddTypedTextChunk(
"private");
2243 if (IsNotInheritanceScope && Results.includeCodePatterns())
2245 Results.AddResult(
Result(Builder.TakeString()));
2258 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
2260 Builder.AddTypedTextChunk(
"template");
2262 Builder.AddPlaceholderChunk(
"parameters");
2264 Results.AddResult(
Result(Builder.TakeString()));
2297 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
2299 Builder.AddTypedTextChunk(
"try");
2303 Builder.AddPlaceholderChunk(
"statements");
2307 Builder.AddTextChunk(
"catch");
2310 Builder.AddPlaceholderChunk(
"declaration");
2315 Builder.AddPlaceholderChunk(
"statements");
2318 Results.AddResult(
Result(Builder.TakeString()));
2323 if (Results.includeCodePatterns()) {
2325 Builder.AddTypedTextChunk(
"if");
2329 Builder.AddPlaceholderChunk(
"condition");
2331 Builder.AddPlaceholderChunk(
"expression");
2336 Builder.AddPlaceholderChunk(
"statements");
2339 Results.AddResult(
Result(Builder.TakeString()));
2342 Builder.AddTypedTextChunk(
"switch");
2346 Builder.AddPlaceholderChunk(
"condition");
2348 Builder.AddPlaceholderChunk(
"expression");
2353 Builder.AddPlaceholderChunk(
"cases");
2356 Results.AddResult(
Result(Builder.TakeString()));
2363 Builder.AddTypedTextChunk(
"case");
2365 Builder.AddPlaceholderChunk(
"expression");
2367 Results.AddResult(
Result(Builder.TakeString()));
2370 Builder.AddTypedTextChunk(
"default");
2372 Results.AddResult(
Result(Builder.TakeString()));
2375 if (Results.includeCodePatterns()) {
2377 Builder.AddTypedTextChunk(
"while");
2381 Builder.AddPlaceholderChunk(
"condition");
2383 Builder.AddPlaceholderChunk(
"expression");
2388 Builder.AddPlaceholderChunk(
"statements");
2391 Results.AddResult(
Result(Builder.TakeString()));
2394 Builder.AddTypedTextChunk(
"do");
2398 Builder.AddPlaceholderChunk(
"statements");
2401 Builder.AddTextChunk(
"while");
2404 Builder.AddPlaceholderChunk(
"expression");
2406 Results.AddResult(
Result(Builder.TakeString()));
2409 Builder.AddTypedTextChunk(
"for");
2413 Builder.AddPlaceholderChunk(
"init-statement");
2415 Builder.AddPlaceholderChunk(
"init-expression");
2418 Builder.AddPlaceholderChunk(
"condition");
2421 Builder.AddPlaceholderChunk(
"inc-expression");
2426 Builder.AddPlaceholderChunk(
"statements");
2429 Results.AddResult(
Result(Builder.TakeString()));
2433 Builder.AddTypedTextChunk(
"for");
2436 Builder.AddPlaceholderChunk(
"range-declaration");
2439 Builder.AddTextChunk(
"in");
2443 Builder.AddPlaceholderChunk(
"range-expression");
2448 Builder.AddPlaceholderChunk(
"statements");
2451 Results.AddResult(
Result(Builder.TakeString()));
2455 if (S->getContinueParent()) {
2457 Builder.AddTypedTextChunk(
"continue");
2459 Results.AddResult(
Result(Builder.TakeString()));
2462 if (S->getBreakParent()) {
2464 Builder.AddTypedTextChunk(
"break");
2466 Results.AddResult(
Result(Builder.TakeString()));
2472 ReturnType =
Function->getReturnType();
2473 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
2479 Builder.AddTypedTextChunk(
"return");
2481 Results.AddResult(
Result(Builder.TakeString()));
2483 assert(!ReturnType.
isNull());
2485 Builder.AddTypedTextChunk(
"return");
2487 Builder.AddPlaceholderChunk(
"expression");
2489 Results.AddResult(
Result(Builder.TakeString()));
2492 Builder.AddTypedTextChunk(
"return true");
2494 Results.AddResult(
Result(Builder.TakeString()));
2496 Builder.AddTypedTextChunk(
"return false");
2498 Results.AddResult(
Result(Builder.TakeString()));
2503 Builder.AddTypedTextChunk(
"return nullptr");
2505 Results.AddResult(
Result(Builder.TakeString()));
2510 Builder.AddTypedTextChunk(
"goto");
2512 Builder.AddPlaceholderChunk(
"label");
2514 Results.AddResult(
Result(Builder.TakeString()));
2517 Builder.AddTypedTextChunk(
"using namespace");
2519 Builder.AddPlaceholderChunk(
"identifier");
2521 Results.AddResult(
Result(Builder.TakeString()));
2538 Builder.AddTypedTextChunk(
"__bridge");
2540 Builder.AddPlaceholderChunk(
"type");
2542 Builder.AddPlaceholderChunk(
"expression");
2543 Results.AddResult(
Result(Builder.TakeString()));
2546 Builder.AddTypedTextChunk(
"__bridge_transfer");
2548 Builder.AddPlaceholderChunk(
"Objective-C type");
2550 Builder.AddPlaceholderChunk(
"expression");
2551 Results.AddResult(
Result(Builder.TakeString()));
2554 Builder.AddTypedTextChunk(
"__bridge_retained");
2556 Builder.AddPlaceholderChunk(
"CF type");
2558 Builder.AddPlaceholderChunk(
"expression");
2559 Results.AddResult(
Result(Builder.TakeString()));
2570 Builder.AddResultTypeChunk(
"bool");
2571 Builder.AddTypedTextChunk(
"true");
2572 Results.AddResult(
Result(Builder.TakeString()));
2575 Builder.AddResultTypeChunk(
"bool");
2576 Builder.AddTypedTextChunk(
"false");
2577 Results.AddResult(
Result(Builder.TakeString()));
2581 Builder.AddTypedTextChunk(
"dynamic_cast");
2583 Builder.AddPlaceholderChunk(
"type");
2586 Builder.AddPlaceholderChunk(
"expression");
2588 Results.AddResult(
Result(Builder.TakeString()));
2592 Builder.AddTypedTextChunk(
"static_cast");
2594 Builder.AddPlaceholderChunk(
"type");
2597 Builder.AddPlaceholderChunk(
"expression");
2599 Results.AddResult(
Result(Builder.TakeString()));
2602 Builder.AddTypedTextChunk(
"reinterpret_cast");
2604 Builder.AddPlaceholderChunk(
"type");
2607 Builder.AddPlaceholderChunk(
"expression");
2609 Results.AddResult(
Result(Builder.TakeString()));
2612 Builder.AddTypedTextChunk(
"const_cast");
2614 Builder.AddPlaceholderChunk(
"type");
2617 Builder.AddPlaceholderChunk(
"expression");
2619 Results.AddResult(
Result(Builder.TakeString()));
2623 Builder.AddResultTypeChunk(
"std::type_info");
2624 Builder.AddTypedTextChunk(
"typeid");
2626 Builder.AddPlaceholderChunk(
"expression-or-type");
2628 Results.AddResult(
Result(Builder.TakeString()));
2632 Builder.AddTypedTextChunk(
"new");
2634 Builder.AddPlaceholderChunk(
"type");
2636 Builder.AddPlaceholderChunk(
"expressions");
2638 Results.AddResult(
Result(Builder.TakeString()));
2641 Builder.AddTypedTextChunk(
"new");
2643 Builder.AddPlaceholderChunk(
"type");
2645 Builder.AddPlaceholderChunk(
"size");
2648 Builder.AddPlaceholderChunk(
"expressions");
2650 Results.AddResult(
Result(Builder.TakeString()));
2653 Builder.AddResultTypeChunk(
"void");
2654 Builder.AddTypedTextChunk(
"delete");
2656 Builder.AddPlaceholderChunk(
"expression");
2657 Results.AddResult(
Result(Builder.TakeString()));
2660 Builder.AddResultTypeChunk(
"void");
2661 Builder.AddTypedTextChunk(
"delete");
2666 Builder.AddPlaceholderChunk(
"expression");
2667 Results.AddResult(
Result(Builder.TakeString()));
2671 Builder.AddResultTypeChunk(
"void");
2672 Builder.AddTypedTextChunk(
"throw");
2674 Builder.AddPlaceholderChunk(
"expression");
2675 Results.AddResult(
Result(Builder.TakeString()));
2682 Builder.AddResultTypeChunk(
"std::nullptr_t");
2683 Builder.AddTypedTextChunk(
"nullptr");
2684 Results.AddResult(
Result(Builder.TakeString()));
2687 Builder.AddResultTypeChunk(
"size_t");
2688 Builder.AddTypedTextChunk(
"alignof");
2690 Builder.AddPlaceholderChunk(
"type");
2692 Results.AddResult(
Result(Builder.TakeString()));
2695 Builder.AddResultTypeChunk(
"bool");
2696 Builder.AddTypedTextChunk(
"noexcept");
2698 Builder.AddPlaceholderChunk(
"expression");
2700 Results.AddResult(
Result(Builder.TakeString()));
2703 Builder.AddResultTypeChunk(
"size_t");
2704 Builder.AddTypedTextChunk(
"sizeof...");
2706 Builder.AddPlaceholderChunk(
"parameter-pack");
2708 Results.AddResult(
Result(Builder.TakeString()));
2717 if (ID->getSuperClass()) {
2718 std::string SuperType;
2719 SuperType = ID->getSuperClass()->getNameAsString();
2720 if (Method->isInstanceMethod())
2723 Builder.AddResultTypeChunk(Allocator.CopyString(SuperType));
2724 Builder.AddTypedTextChunk(
"super");
2725 Results.AddResult(
Result(Builder.TakeString()));
2734 Builder.AddResultTypeChunk(
"size_t");
2736 Builder.AddTypedTextChunk(
"alignof");
2738 Builder.AddTypedTextChunk(
"_Alignof");
2740 Builder.AddPlaceholderChunk(
"type");
2742 Results.AddResult(
Result(Builder.TakeString()));
2747 Builder.AddResultTypeChunk(
"nullptr_t");
2748 Builder.AddTypedTextChunk(
"nullptr");
2749 Results.AddResult(
Result(Builder.TakeString()));
2753 Builder.AddResultTypeChunk(
"size_t");
2754 Builder.AddTypedTextChunk(
"sizeof");
2756 Builder.AddPlaceholderChunk(
"expression-or-type");
2758 Results.AddResult(
Result(Builder.TakeString()));
2771 Results.AddResult(
Result(
"operator"));
2792 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2794 T = Method->getSendResultType(BaseType);
2797 }
else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2800 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2802 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2804 T = Ivar->getUsageType(BaseType);
2806 T = Ivar->getType();
2807 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
2809 }
else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND)) {
2819 Result.AddResultTypeChunk(
2826 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2827 if (Sentinel->getSentinel() == 0) {
2829 Result.AddTextChunk(
", nil");
2831 Result.AddTextChunk(
", NULL");
2833 Result.AddTextChunk(
", (void*)0");
2854 switch (*nullability) {
2864 Result +=
"null_unspecified ";
2868 llvm_unreachable(
"Not supported as a context-sensitive keyword!");
2885 bool SuppressBlock =
false) {
2891 if (!SuppressBlock) {
2894 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2907 TL = AttrTL.getModifiedLoc();
2926 bool SuppressBlockName =
false,
bool SuppressBlock =
false,
2931 bool SuppressName =
false,
bool SuppressBlock =
false,
2939 if (
const auto *PVD = dyn_cast<ParmVarDecl>(Param))
2940 ObjCQual = PVD->getObjCDeclQualifier();
2941 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2948 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2955 if (ObjCMethodParam) {
2974 if (!
Block && ObjCMethodParam &&
2975 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
2976 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
2977 ->findPropertyDecl(
false))
2991 if (ObjCMethodParam) {
2996 if (
Result.back() !=
')')
3010 false, SuppressBlock,
3026 bool SuppressBlockName,
bool SuppressBlock,
3034 if (!ResultType->
isVoidType() || SuppressBlock)
3039 if (!BlockProto ||
Block.getNumParams() == 0) {
3046 for (
unsigned I = 0, N =
Block.getNumParams(); I != N; ++I) {
3059 if (SuppressBlock) {
3062 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3071 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3091 if (srcText.empty() || srcText ==
"=") {
3097 std::string DefValue(srcText.str());
3100 if (DefValue.at(0) !=
'=') {
3104 return " = " + DefValue;
3106 return " " + DefValue;
3115 bool InOptional =
false) {
3116 bool FirstParameter =
true;
3118 for (
unsigned P = Start, N =
Function->getNumParams();
P != N; ++
P) {
3125 Result.getCodeCompletionTUInfo());
3126 if (!FirstParameter)
3134 FirstParameter =
false;
3146 if (
Function->isVariadic() &&
P == N - 1)
3147 PlaceholderStr +=
", ...";
3150 Result.AddPlaceholderChunk(
3151 Result.getAllocator().CopyString(PlaceholderStr));
3155 if (Proto->isVariadic()) {
3156 if (Proto->getNumParams() == 0)
3157 Result.AddPlaceholderChunk(
"...");
3167 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false) {
3168 bool FirstParameter =
true;
3177 PEnd = Params->
begin() + MaxParameters;
3180 bool HasDefaultArg =
false;
3181 std::string PlaceholderStr;
3183 if (TTP->wasDeclaredWithTypename())
3184 PlaceholderStr =
"typename";
3185 else if (
const auto *TC = TTP->getTypeConstraint()) {
3186 llvm::raw_string_ostream OS(PlaceholderStr);
3187 TC->print(OS, Policy);
3189 PlaceholderStr =
"class";
3191 if (TTP->getIdentifier()) {
3192 PlaceholderStr +=
' ';
3193 PlaceholderStr += TTP->getIdentifier()->deuglifiedName();
3196 HasDefaultArg = TTP->hasDefaultArgument();
3198 dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
3199 if (NTTP->getIdentifier())
3200 PlaceholderStr = std::string(NTTP->getIdentifier()->deuglifiedName());
3201 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
3202 HasDefaultArg = NTTP->hasDefaultArgument();
3204 assert(isa<TemplateTemplateParmDecl>(*
P));
3209 PlaceholderStr =
"template<...> class";
3211 PlaceholderStr +=
' ';
3218 if (HasDefaultArg && !InDefaultArg) {
3222 Result.getCodeCompletionTUInfo());
3223 if (!FirstParameter)
3226 P - Params->
begin(),
true);
3231 InDefaultArg =
false;
3234 FirstParameter =
false;
3239 Result.AddPlaceholderChunk(
3240 Result.getAllocator().CopyString(PlaceholderStr));
3248 bool QualifierIsInformative,
3254 std::string PrintedNNS;
3256 llvm::raw_string_ostream OS(PrintedNNS);
3257 Qualifier->print(OS, Policy);
3259 if (QualifierIsInformative)
3260 Result.AddInformativeChunk(
Result.getAllocator().CopyString(PrintedNNS));
3262 Result.AddTextChunk(
Result.getAllocator().CopyString(PrintedNNS));
3269 if (!Proto || !Proto->getMethodQuals())
3275 if (Proto->getMethodQuals().hasOnlyConst()) {
3276 Result.AddInformativeChunk(
" const");
3280 if (Proto->getMethodQuals().hasOnlyVolatile()) {
3281 Result.AddInformativeChunk(
" volatile");
3285 if (Proto->getMethodQuals().hasOnlyRestrict()) {
3286 Result.AddInformativeChunk(
" restrict");
3291 std::string QualsStr;
3292 if (Proto->isConst())
3293 QualsStr +=
" const";
3294 if (Proto->isVolatile())
3295 QualsStr +=
" volatile";
3296 if (Proto->isRestrict())
3297 QualsStr +=
" restrict";
3298 Result.AddInformativeChunk(
Result.getAllocator().CopyString(QualsStr));
3309 switch (Name.getNameKind()) {
3311 const char *OperatorName =
nullptr;
3312 switch (Name.getCXXOverloadedOperator()) {
3314 case OO_Conditional:
3316 OperatorName =
"operator";
3319#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
3321 OperatorName = "operator" Spelling; \
3323#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly)
3324#include "clang/Basic/OperatorKinds.def"
3327 OperatorName =
"operator new";
3330 OperatorName =
"operator delete";
3333 OperatorName =
"operator new[]";
3335 case OO_Array_Delete:
3336 OperatorName =
"operator delete[]";
3339 OperatorName =
"operator()";
3342 OperatorName =
"operator[]";
3345 Result.AddTypedTextChunk(OperatorName);
3353 Result.AddTypedTextChunk(
3366 QualType Ty = Name.getCXXNameType();
3368 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
3370 Record = InjectedTy->getDecl();
3372 Result.AddTypedTextChunk(
3377 Result.AddTypedTextChunk(
3378 Result.getAllocator().CopyString(
Record->getNameAsString()));
3392 bool IncludeBriefComments) {
3394 CCTUInfo, IncludeBriefComments);
3406 return Result.TakeString();
3417 Result.AddPlaceholderChunk(
"...");
3431 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3436 Result.AddPlaceholderChunk(
3437 Result.getAllocator().CopyString((*A)->getName()));
3440 return Result.TakeString();
3452 bool IncludeBriefComments) {
3468 Result.addBriefComment(RC->getBriefText(Ctx));
3478 return Result.TakeString();
3482 PP, Ctx,
Result, IncludeBriefComments, CCContext, Policy);
3486 std::string &BeforeName,
3487 std::string &NameAndSignature) {
3488 bool SeenTypedChunk =
false;
3489 for (
auto &Chunk : CCS) {
3491 assert(SeenTypedChunk &&
"optional parameter before name");
3498 NameAndSignature += Chunk.Text;
3500 BeforeName += Chunk.Text;
3512 std::string BeforeName;
3513 std::string NameAndSignature;
3516 NameAndSignature +=
" override";
3518 Result.AddTextChunk(
Result.getAllocator().CopyString(BeforeName));
3520 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(NameAndSignature));
3521 return Result.TakeString();
3527 const auto *VD = dyn_cast<VarDecl>(ND);
3530 const auto *
RecordDecl = VD->getType()->getAsCXXRecordDecl();
3543 if (IncludeBriefComments) {
3546 Result.addBriefComment(RC->getBriefText(Ctx));
3551 Result.AddTypedTextChunk(
3553 Result.AddTextChunk(
"::");
3554 return Result.TakeString();
3558 Result.AddAnnotation(
Result.getAllocator().CopyString(I->getAnnotation()));
3571 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND)) {
3572 AddFunctionTypeAndResult(
Function);
3573 return Result.TakeString();
3576 if (
const auto *CallOperator =
3578 AddFunctionTypeAndResult(CallOperator);
3579 return Result.TakeString();
3585 dyn_cast<FunctionTemplateDecl>(ND)) {
3596 llvm::SmallBitVector Deduced(FunTmpl->getTemplateParameters()->size());
3601 unsigned LastDeducibleArgument;
3602 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
3603 --LastDeducibleArgument) {
3604 if (!Deduced[LastDeducibleArgument - 1]) {
3608 bool HasDefaultArg =
false;
3609 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3610 LastDeducibleArgument - 1);
3612 HasDefaultArg = TTP->hasDefaultArgument();
3614 dyn_cast<NonTypeTemplateParmDecl>(Param))
3615 HasDefaultArg = NTTP->hasDefaultArgument();
3617 assert(isa<TemplateTemplateParmDecl>(Param));
3619 cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
3642 LastDeducibleArgument);
3651 return Result.TakeString();
3654 if (
const auto *Template = dyn_cast<TemplateDecl>(ND)) {
3657 Result.AddTypedTextChunk(
3658 Result.getAllocator().CopyString(Template->getNameAsString()));
3662 return Result.TakeString();
3665 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3666 Selector Sel = Method->getSelector();
3668 Result.AddTypedTextChunk(
3670 return Result.TakeString();
3676 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(SelName));
3678 Result.AddInformativeChunk(
Result.getAllocator().CopyString(SelName));
3683 Result.AddTypedTextChunk(
"");
3690 P != PEnd && Idx < Sel.
getNumArgs(); (
void)++
P, ++Idx) {
3709 QualType ParamType = (*P)->getType();
3710 std::optional<ArrayRef<QualType>> ObjCSubsts;
3726 Arg += II->getName();
3733 Result.AddTextChunk(
Result.getAllocator().CopyString(Arg));
3735 Result.AddInformativeChunk(
Result.getAllocator().CopyString(Arg));
3737 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3743 Result.AddTextChunk(
", ...");
3745 Result.AddInformativeChunk(
", ...");
3747 Result.AddPlaceholderChunk(
", ...");
3753 return Result.TakeString();
3760 Result.AddTypedTextChunk(
3762 return Result.TakeString();
3773 const auto *M = dyn_cast<ObjCMethodDecl>(ND);
3785 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
3786 if (!M || !M->isPropertyAccessor())
3809 auto FDecl =
Result.getFunction();
3812 if (ArgIndex < FDecl->getNumParams())
3820 unsigned CurrentArg) {
3821 unsigned ChunkIndex = 0;
3822 auto AddChunk = [&](llvm::StringRef Placeholder) {
3825 const char *
Copy =
Result.getAllocator().CopyString(Placeholder);
3826 if (ChunkIndex == CurrentArg)
3834 if (
auto *CRD = llvm::dyn_cast<CXXRecordDecl>(RD)) {
3835 for (
const auto &
Base : CRD->bases())
3836 AddChunk(
Base.getType().getAsString(Policy));
3838 for (
const auto &Field : RD->
fields())
3848 unsigned CurrentArg,
unsigned Start = 0,
bool InOptional =
false) {
3854 bool FirstParameter =
true;
3855 unsigned NumParams =
3858 for (
unsigned P = Start;
P != NumParams; ++
P) {
3863 Result.getCodeCompletionTUInfo());
3864 if (!FirstParameter)
3868 PrototypeLoc, Opt, CurrentArg,
P,
3875 FirstParameter =
false;
3882 std::string Placeholder;
3883 assert(P < Prototype->getNumParams());
3892 Placeholder =
Prototype->getParamType(
P).getAsString(Policy);
3895 if (
P == CurrentArg)
3896 Result.AddCurrentParameterChunk(
3897 Result.getAllocator().CopyString(Placeholder));
3899 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Placeholder));
3904 Result.getCodeCompletionTUInfo());
3905 if (!FirstParameter)
3908 if (CurrentArg < NumParams)
3920 if (
const auto *
Type = dyn_cast<TemplateTypeParmDecl>(Param)) {
3922 }
else if (
const auto *NonType = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
3923 Optional = NonType->hasDefaultArgument();
3924 }
else if (
const auto *Template = dyn_cast<TemplateTemplateParmDecl>(Param)) {
3925 Optional = Template->hasDefaultArgument();
3928 llvm::raw_string_ostream OS(
Result);
3929 Param->
print(OS, Policy);
3935 if (
const auto *CTD = dyn_cast<ClassTemplateDecl>(TD))
3936 return CTD->getTemplatedDecl()->getKindName().str();
3937 if (
const auto *VTD = dyn_cast<VarTemplateDecl>(TD))
3938 return VTD->getTemplatedDecl()->getType().getAsString(Policy);
3939 if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(TD))
3940 return FTD->getTemplatedDecl()->getReturnType().getAsString(Policy);
3941 if (isa<TypeAliasTemplateDecl>(TD))
3943 if (isa<TemplateTemplateParmDecl>(TD))
3945 if (isa<ConceptDecl>(TD))
3955 Builder.getCodeCompletionTUInfo());
3957 if (!ResultType.empty())
3958 Builder.AddResultTypeChunk(Builder.getAllocator().CopyString(ResultType));
3959 Builder.AddTextChunk(
3965 for (
unsigned I = 0; I < Params.size(); ++I) {
3967 std::string Placeholder =
3970 Current = &OptionalBuilder;
3973 Current->AddChunk(I == CurrentArg
3976 Current->getAllocator().CopyString(Placeholder));
3979 if (Current == &OptionalBuilder)
3980 Builder.AddOptionalChunk(OptionalBuilder.
TakeString());
3984 if (isa<FunctionTemplateDecl>(TD))
3985 Builder.AddInformativeChunk(
"()");
3986 return Builder.TakeString();
3993 bool Braced)
const {
4017 if (IncludeBriefComments) {
4024 llvm::raw_string_ostream OS(Name);
4026 Result.AddTextChunk(
Result.getAllocator().CopyString(Name));
4029 Result.AddResultTypeChunk(
Result.getAllocator().CopyString(
4044 return Result.TakeString();
4049 bool PreferredTypeIsPointer) {
4053 if (MacroName ==
"nil" || MacroName ==
"NULL" || MacroName ==
"Nil") {
4055 if (PreferredTypeIsPointer)
4059 else if (MacroName ==
"YES" || MacroName ==
"NO" || MacroName ==
"true" ||
4060 MacroName ==
"false")
4063 else if (MacroName ==
"bool")
4076 case Decl::EnumConstant:
4080 case Decl::Function:
4082 case Decl::ObjCCategory:
4084 case Decl::ObjCCategoryImpl:
4086 case Decl::ObjCImplementation:
4089 case Decl::ObjCInterface:
4091 case Decl::ObjCIvar:
4093 case Decl::ObjCMethod:
4094 return cast<ObjCMethodDecl>(
D)->isInstanceMethod()
4097 case Decl::CXXMethod:
4099 case Decl::CXXConstructor:
4101 case Decl::CXXDestructor:
4103 case Decl::CXXConversion:
4105 case Decl::ObjCProperty:
4107 case Decl::ObjCProtocol:
4113 case Decl::TypeAlias:
4115 case Decl::TypeAliasTemplate:
4119 case Decl::Namespace:
4121 case Decl::NamespaceAlias:
4123 case Decl::TemplateTypeParm:
4125 case Decl::NonTypeTemplateParm:
4127 case Decl::TemplateTemplateParm:
4129 case Decl::FunctionTemplate:
4131 case Decl::ClassTemplate:
4133 case Decl::AccessSpec:
4135 case Decl::ClassTemplatePartialSpecialization:
4137 case Decl::UsingDirective:
4139 case Decl::StaticAssert:
4143 case Decl::TranslationUnit:
4147 case Decl::UnresolvedUsingValue:
4148 case Decl::UnresolvedUsingTypename:
4151 case Decl::UsingEnum:
4154 case Decl::ObjCPropertyImpl:
4155 switch (cast<ObjCPropertyImplDecl>(
D)->getPropertyImplementation()) {
4162 llvm_unreachable(
"Unexpected Kind!");
4167 case Decl::ObjCTypeParam:
4173 case Decl::LinkageSpec:
4177 if (
const auto *TD = dyn_cast<TagDecl>(
D)) {
4178 switch (TD->getTagKind()) {
4196 bool LoadExternal,
bool IncludeUndefined,
4197 bool TargetTypeIsPointer =
false) {
4200 Results.EnterNewScope();
4206 if (IncludeUndefined || MD) {
4214 TargetTypeIsPointer)));
4218 Results.ExitScope();
4222 ResultBuilder &Results) {
4225 Results.EnterNewScope();
4229 if (LangOpts.C99 || LangOpts.CPlusPlus11)
4231 Results.ExitScope();
4238 unsigned NumResults) {
4301 llvm_unreachable(
"Invalid ParserCompletionContext!");
4313 ResultBuilder &Results) {
4316 while (isa<BlockDecl>(CurContext))
4319 CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(CurContext);
4326 if (!
P->getDeclName())
4332 Results.getCodeCompletionTUInfo());
4339 S.
Context, CurContext, Overridden->getDeclContext());
4342 llvm::raw_string_ostream OS(Str);
4343 NNS->
print(OS, Policy);
4344 Builder.AddTextChunk(Results.getAllocator().CopyString(Str));
4346 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
4349 Builder.AddTypedTextChunk(
4350 Results.getAllocator().CopyString(Overridden->getNameAsString()));
4352 bool FirstParam =
true;
4359 Builder.AddPlaceholderChunk(
4360 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
4366 Results.Ignore(Overridden);
4373 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4374 CodeCompleter->getCodeCompletionTUInfo(),
4376 Results.EnterNewScope();
4385 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
4386 Builder.AddTypedTextChunk(
4387 Builder.getAllocator().CopyString(Modules[I]->Name));
4388 Results.AddResult(
Result(
4393 }
else if (getLangOpts().Modules) {
4401 Builder.AddTypedTextChunk(
4402 Builder.getAllocator().CopyString(Submodule->Name));
4403 Results.AddResult(
Result(
4410 Results.ExitScope();
4412 Results.getCompletionContext(), Results.data(),
4418 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4419 CodeCompleter->getCodeCompletionTUInfo(),
4421 Results.EnterNewScope();
4426 switch (CompletionContext) {
4429 case PCC_ObjCInterface:
4430 case PCC_ObjCImplementation:
4431 case PCC_ObjCInstanceVariableList:
4433 case PCC_MemberTemplate:
4435 case PCC_LocalDeclarationSpecifiers:
4436 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
4440 case PCC_TopLevelOrExpression:
4441 case PCC_ParenthesizedExpression:
4442 case PCC_Expression:
4446 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4448 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4454 case PCC_RecoveryInFunction:
4462 if (!ThisType.isNull())
4463 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
4466 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4468 CodeCompleter->includeGlobals(),
4469 CodeCompleter->loadExternal());
4472 Results.ExitScope();
4474 switch (CompletionContext) {
4475 case PCC_ParenthesizedExpression:
4476 case PCC_Expression:
4478 case PCC_TopLevelOrExpression:
4479 case PCC_RecoveryInFunction:
4480 if (S->getFnParent())
4486 case PCC_ObjCInterface:
4487 case PCC_ObjCImplementation:
4488 case PCC_ObjCInstanceVariableList:
4490 case PCC_MemberTemplate:
4494 case PCC_LocalDeclarationSpecifiers:
4498 if (CodeCompleter->includeMacros())
4502 Results.getCompletionContext(), Results.data(),
4509 bool AtArgumentExpression,
bool IsSuper,
4510 ResultBuilder &Results);
4513 bool AllowNonIdentifiers,
4514 bool AllowNestedNameSpecifiers) {
4516 ResultBuilder Results(
4517 SemaRef, CodeCompleter->getAllocator(),
4518 CodeCompleter->getCodeCompletionTUInfo(),
4519 AllowNestedNameSpecifiers
4524 Results.EnterNewScope();
4527 Results.AddResult(
Result(
"const"));
4528 Results.AddResult(
Result(
"volatile"));
4529 if (getLangOpts().
C99)
4530 Results.AddResult(
Result(
"restrict"));
4536 Results.AddResult(
"final");
4538 if (AllowNonIdentifiers) {
4539 Results.AddResult(
Result(
"operator"));
4543 if (AllowNestedNameSpecifiers) {
4544 Results.allowNestedNameSpecifiers();
4545 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
4546 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4548 Consumer, CodeCompleter->includeGlobals(),
4549 CodeCompleter->loadExternal());
4550 Results.setFilter(
nullptr);
4553 Results.ExitScope();
4559 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
4579 Results.getCompletionContext(), Results.data(),
4584 if (
Scope ==
"clang")
4592 if (
Scope ==
"_Clang")
4594 if (
Scope ==
"__gnu__")
4602 if (Completion == AttributeCompletion::None)
4604 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4605 CodeCompleter->getCodeCompletionTUInfo(),
4618 llvm::StringRef InScopeName;
4619 bool InScopeUnderscore =
false;
4621 InScopeName = InScope->
getName();
4623 InScopeName = NoUnderscore;
4624 InScopeUnderscore =
true;
4631 llvm::DenseSet<llvm::StringRef> FoundScopes;
4633 if (A.IsTargetSpecific &&
4634 !A.existsInTarget(getASTContext().getTargetInfo()))
4636 if (!A.acceptsLangOpts(getLangOpts()))
4638 for (
const auto &S : A.Spellings) {
4639 if (S.Syntax != Syntax)
4641 llvm::StringRef Name = S.NormalizedFullName;
4642 llvm::StringRef
Scope;
4645 std::tie(
Scope, Name) = Name.split(
"::");
4647 std::swap(Name,
Scope);
4651 if (Completion == AttributeCompletion::Scope) {
4653 if (!
Scope.empty() && FoundScopes.insert(
Scope).second) {
4664 if (!InScopeName.empty()) {
4665 if (
Scope != InScopeName)
4670 auto Add = [&](llvm::StringRef
Scope, llvm::StringRef Name,
4673 Results.getCodeCompletionTUInfo());
4675 if (!
Scope.empty()) {
4684 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
Text));
4686 if (!A.ArgNames.empty()) {
4689 for (
const char *Arg : A.ArgNames) {
4693 Builder.AddPlaceholderChunk(Arg);
4698 Results.AddResult(Builder.TakeString());
4705 if (!InScopeUnderscore)
4706 Add(
Scope, Name,
false);
4711 if (!(InScope && !InScopeUnderscore) && SyntaxSupportsGuards) {
4713 if (
Scope.empty()) {
4714 Add(
Scope, Name,
true);
4719 Add(GuardedScope, Name,
true);
4729 for (
const auto &Entry : ParsedAttrInfoRegistry::entries())
4730 AddCompletions(*Entry.instantiate());
4733 Results.getCompletionContext(), Results.data(),
4739 bool IsParenthesized =
false)
4740 : PreferredType(PreferredType), IntegralConstantExpression(
false),
4741 ObjCCollection(
false), IsParenthesized(IsParenthesized) {}
4752struct CoveredEnumerators {
4760 const CoveredEnumerators &Enumerators) {
4762 if (Context.
getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) {
4769 Results.EnterNewScope();
4770 for (
auto *
E :
Enum->enumerators()) {
4771 if (Enumerators.Seen.count(
E))
4775 Results.AddResult(R, CurContext,
nullptr,
false);
4777 Results.ExitScope();
4783 assert(!
T.isNull());
4806 if (!Results.includeCodePatterns())
4809 Results.getCodeCompletionTUInfo());
4814 if (!Parameters.empty()) {
4823 constexpr llvm::StringLiteral NamePlaceholder =
"!#!NAME_GOES_HERE!#!";
4824 std::string
Type = std::string(NamePlaceholder);
4826 llvm::StringRef Prefix, Suffix;
4827 std::tie(Prefix, Suffix) = llvm::StringRef(
Type).split(NamePlaceholder);
4828 Prefix = Prefix.rtrim();
4829 Suffix = Suffix.ltrim();
4852 ResultBuilder Results(
4853 SemaRef, CodeCompleter->getAllocator(),
4854 CodeCompleter->getCodeCompletionTUInfo(),
4856 Data.IsParenthesized
4859 Data.PreferredType));
4861 Data.IsParenthesized ? PCC_ParenthesizedExpression : PCC_Expression;
4862 if (
Data.ObjCCollection)
4863 Results.setFilter(&ResultBuilder::IsObjCCollection);
4864 else if (
Data.IntegralConstantExpression)
4865 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
4867 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4869 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4871 if (!
Data.PreferredType.isNull())
4872 Results.setPreferredType(
Data.PreferredType.getNonReferenceType());
4875 for (
unsigned I = 0, N =
Data.IgnoreDecls.size(); I != N; ++I)
4876 Results.Ignore(
Data.IgnoreDecls[I]);
4878 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4880 CodeCompleter->includeGlobals(),
4881 CodeCompleter->loadExternal());
4883 Results.EnterNewScope();
4885 Results.ExitScope();
4887 bool PreferredTypeIsPointer =
false;
4888 if (!
Data.PreferredType.isNull()) {
4889 PreferredTypeIsPointer =
Data.PreferredType->isAnyPointerType() ||
4890 Data.PreferredType->isMemberPointerType() ||
4891 Data.PreferredType->isBlockPointerType();
4892 if (
Data.PreferredType->isEnumeralType()) {
4894 if (
auto *Def =
Enum->getDefinition())
4899 CoveredEnumerators());
4903 if (S->getFnParent() && !
Data.ObjCCollection &&
4904 !
Data.IntegralConstantExpression)
4907 if (CodeCompleter->includeMacros())
4909 PreferredTypeIsPointer);
4919 Results.getCompletionContext(), Results.data(),
4925 bool IsParenthesized) {
4926 return CodeCompleteExpression(
4933 CodeCompleteExpression(S, PreferredType);
4934 else if (getLangOpts().
ObjC)
4935 CodeCompleteObjCInstanceMessage(S,
E.get(), std::nullopt,
false);
4952 if (Protocol->hasDefinition())
4953 return Protocol->getDefinition();
4967 Builder.AddResultTypeChunk(
4969 Policy, Builder.getAllocator()));
4975 Builder.AddPlaceholderChunk(
"...");
4977 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
4982 std::string PlaceholderStr =
4985 if (I == N - 1 && BlockProtoLoc &&
4987 PlaceholderStr +=
", ...";
4990 Builder.AddPlaceholderChunk(
4991 Builder.getAllocator().CopyString(PlaceholderStr));
5001 bool AllowNullaryMethods,
DeclContext *CurContext,
5003 bool IsBaseExprStatement =
false,
5004 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
5012 if (!AddedProperties.insert(
P->getIdentifier()).second)
5017 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
5018 !IsBaseExprStatement) {
5020 if (!InOriginalClass)
5022 Results.MaybeAddResult(R, CurContext);
5034 if (!InOriginalClass)
5036 Results.MaybeAddResult(R, CurContext);
5043 Results.getCodeCompletionTUInfo());
5046 BlockLoc, BlockProtoLoc);
5047 Result R =
Result(Builder.TakeString(),
P, Results.getBasePriority(
P));
5048 if (!InOriginalClass)
5050 Results.MaybeAddResult(R, CurContext);
5054 if (!
P->isReadOnly()) {
5056 Results.getCodeCompletionTUInfo());
5060 Builder.AddTypedTextChunk(
5061 Results.getAllocator().CopyString(
P->getName()));
5066 BlockProtoLoc,
true);
5068 Builder.AddPlaceholderChunk(
5069 Builder.getAllocator().CopyString(PlaceholderStr));
5077 Result(Builder.TakeString(),
P,
5078 Results.getBasePriority(
P) +
5082 if (!InOriginalClass)
5084 Results.MaybeAddResult(R, CurContext);
5088 if (IsClassProperty) {
5089 for (
const auto *
P : Container->class_properties())
5092 for (
const auto *
P : Container->instance_properties())
5097 if (AllowNullaryMethods) {
5098 ASTContext &Context = Container->getASTContext();
5102 const IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
5105 if (!AddedProperties.insert(Name).second)
5108 Results.getCodeCompletionTUInfo());
5110 Builder.AddTypedTextChunk(
5111 Results.getAllocator().CopyString(Name->getName()));
5114 if (!InOriginalClass)
5116 Results.MaybeAddResult(R, CurContext);
5119 if (IsClassProperty) {
5120 for (
const auto *M : Container->methods()) {
5124 if (!M->getSelector().isUnarySelector() ||
5125 M->getReturnType()->isVoidType() || M->isInstanceMethod())
5130 for (
auto *M : Container->methods()) {
5131 if (M->getSelector().isUnarySelector())
5139 for (
auto *
P : Protocol->protocols())
5141 CurContext, AddedProperties, Results,
5142 IsBaseExprStatement, IsClassProperty,
5145 dyn_cast<ObjCInterfaceDecl>(Container)) {
5146 if (AllowCategories) {
5148 for (
auto *Cat : IFace->known_categories())
5150 CurContext, AddedProperties, Results,
5151 IsBaseExprStatement, IsClassProperty,
5156 for (
auto *I : IFace->all_referenced_protocols())
5158 CurContext, AddedProperties, Results,
5159 IsBaseExprStatement, IsClassProperty,
5163 if (IFace->getSuperClass())
5165 AllowNullaryMethods, CurContext, AddedProperties,
5166 Results, IsBaseExprStatement, IsClassProperty,
5169 dyn_cast<ObjCCategoryDecl>(Container)) {
5173 CurContext, AddedProperties, Results,
5174 IsBaseExprStatement, IsClassProperty,
5183 std::optional<FixItHint> AccessOpFixIt) {
5186 Results.setObjectTypeQualifiers(BaseType.
getQualifiers(), BaseKind);
5189 Results.allowNestedNameSpecifiers();
5190 std::vector<FixItHint> FixIts;
5192 FixIts.emplace_back(*AccessOpFixIt);
5193 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
5201 if (!Results.empty()) {
5207 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->getParent())
5226 if (
const auto *CTSD =
5227 llvm::dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
5231 RD = CTSD->getSpecializedTemplate()->getTemplatedDecl();
5237 if (
const auto *TD = dyn_cast_or_null<ClassTemplateDecl>(
5238 TST->getTemplateName().getAsTemplateDecl())) {
5239 return TD->getTemplatedDecl();
5283 std::optional<SmallVector<QualType, 1>> ArgTypes;
5285 enum AccessOperator {
5302 std::string AsString;
5304 llvm::raw_string_ostream OS(AsString);
5305 QualType ExactType = deduceType(*ResultType);
5311 B.AddResultTypeChunk(
Alloc.CopyString(AsString));
5314 B.AddTypedTextChunk(
Alloc.CopyString(Name->getName()));
5326 B.AddPlaceholderChunk(
Alloc.CopyString(
5331 return B.TakeString();
5339 auto *TemplatedEntity = getTemplatedEntity(BaseType.
getDecl(), S);
5340 for (
const Expr *
E : constraintsForTemplatedEntity(TemplatedEntity))
5341 believe(
E, &BaseType);
5344 std::vector<Member> members() {
5345 std::vector<Member> Results;
5346 for (
const auto &
E : this->Results)
5347 Results.push_back(
E.second);
5348 llvm::sort(Results, [](
const Member &L,
const Member &R) {
5349 return L.Name->getName() < R.Name->getName();
5359 if (
auto *CSE = dyn_cast<ConceptSpecializationExpr>(
E)) {
5373 for (
const auto &Arg : CSE->getTemplateArguments()) {
5374 if (Index >= Params->
size())
5376 if (isApprox(Arg,
T)) {
5377 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Params->
getParam(Index));
5381 auto *TT = cast<TemplateTypeParmType>(TTPD->getTypeForDecl());
5389 }
else if (
auto *BO = dyn_cast<BinaryOperator>(
E)) {
5392 if (BO->getOpcode() == BO_LAnd || BO->getOpcode() == BO_LOr) {
5393 believe(BO->getLHS(),
T);
5394 believe(BO->getRHS(),
T);
5396 }
else if (
auto *RE = dyn_cast<RequiresExpr>(
E)) {
5399 if (!Req->isDependent())
5403 if (
auto *TR = dyn_cast<concepts::TypeRequirement>(Req)) {
5405 QualType AssertedType = TR->getType()->getType();
5406 ValidVisitor(
this,
T).TraverseType(AssertedType);
5407 }
else if (
auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
5408 ValidVisitor Visitor(
this,
T);
5412 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
5414 ER->getReturnTypeRequirement().getTypeConstraint();
5415 Visitor.OuterExpr = ER->getExpr();
5417 Visitor.TraverseStmt(ER->getExpr());
5418 }
else if (
auto *NR = dyn_cast<concepts::NestedRequirement>(Req)) {
5419 believe(NR->getConstraintExpr(),
T);
5436 Expr *OuterExpr =
nullptr;
5440 : Outer(Outer),
T(
T) {
5446 const Type *
Base =
E->getBaseType().getTypePtr();
5447 bool IsArrow =
E->isArrow();
5448 if (
Base->isPointerType() && IsArrow) {
5450 Base =
Base->getPointeeType().getTypePtr();
5452 if (isApprox(
Base,
T))
5453 addValue(
E,
E->getMember(), IsArrow ? Member::Arrow : Member::Dot);
5459 if (
E->getQualifier() && isApprox(
E->getQualifier()->getAsType(),
T))
5460 addValue(
E,
E->getDeclName(), Member::Colons);
5467 if (Q && isApprox(Q->getAsType(),
T))
5478 if (Q && isApprox(Q->getAsType(),
T))
5496 void addResult(
Member &&M) {
5497 auto R = Outer->Results.try_emplace(M.Name);
5498 Member &O = R.first->second;
5502 std::make_tuple(M.ArgTypes.has_value(), M.ResultType !=
nullptr,
5503 M.Operator) > std::make_tuple(O.ArgTypes.has_value(),
5504 O.ResultType !=
nullptr,
5514 M.Operator = Member::Colons;
5515 addResult(std::move(M));
5519 Member::AccessOperator Operator) {
5520 if (!Name.isIdentifier())
5523 Result.Name = Name.getAsIdentifierInfo();
5524 Result.Operator = Operator;
5527 if (Caller !=
nullptr && Callee ==
E) {
5528 Result.ArgTypes.emplace();
5529 for (
const auto *Arg : Caller->
arguments())
5530 Result.ArgTypes->push_back(Arg->getType());
5531 if (Caller == OuterExpr) {
5532 Result.ResultType = OuterType;
5536 Result.ResultType = OuterType;
5538 addResult(std::move(Result));
5547 static bool isApprox(
const Type *T1,
const Type *T2) {
5560 Scope *Inner =
nullptr;
5562 if (S->isTemplateParamScope() && S->isDeclScope(
D))
5563 return Inner ? Inner->getEntity() :
nullptr;
5579 TD->getAssociatedConstraints(Result);
5581 if (
const auto *CTPSD =
5582 dyn_cast<ClassTemplatePartialSpecializationDecl>(DC))
5583 CTPSD->getAssociatedConstraints(Result);
5584 if (
const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl>(DC))
5585 VTPSD->getAssociatedConstraints(Result);
5596 if (
const auto *Args =
T.getTemplateArgsAsWritten())
5597 if (Args->getNumTemplateArgs() == 1) {
5598 const auto &Arg = Args->arguments().front().getArgument();
5605 llvm::DenseMap<const IdentifierInfo *, Member> Results;
5618 if (!
Unresolved->isSpecificBuiltinType(BuiltinType::Dependent)) {
5620 if (!
Auto || !
Auto->isUndeducedAutoType())
5624 if (
const CallExpr *CE = llvm::dyn_cast<CallExpr>(
E)) {
5627 Callee->isSpecificPlaceholderType(BuiltinType::BoundMember))
5633 Callee = FnTypePtr->getPointeeType();
5635 Callee = BPT->getPointeeType();
5638 return FnType->getReturnType().getNonReferenceType();
5641 if (
const auto *OE = llvm::dyn_cast<OverloadExpr>(CE->
getCallee())) {
5645 const Type *Common =
nullptr;
5646 for (
const auto *
D : OE->decls()) {
5648 if (
const auto *FD = llvm::dyn_cast<FunctionDecl>(
D))
5649 ReturnType = FD->getReturnType();
5650 else if (
const auto *FTD = llvm::dyn_cast<FunctionTemplateDecl>(
D))
5651 ReturnType = FTD->getTemplatedDecl()->getReturnType();
5654 const Type *Candidate =
5656 if (Common && Common != Candidate)
5660 if (Common !=
nullptr)
5665 if (
const auto *CDSME = llvm::dyn_cast<CXXDependentScopeMemberExpr>(
E)) {
5667 ? CDSME->getBaseType()
5668 : getApproximateType(CDSME->getBase());
5669 if (CDSME->isArrow() && !
Base.isNull())
5675 if (RD && RD->isCompleteDefinition()) {
5677 for (
const auto *
Member : RD->lookupDependentName(
5679 return llvm::isa<ValueDecl>(Member);
5681 return llvm::cast<ValueDecl>(
Member)->getType().getNonReferenceType();
5686 if (
const auto *DRE = llvm::dyn_cast<DeclRefExpr>(
E)) {
5687 if (
const auto *VD = llvm::dyn_cast<VarDecl>(DRE->getDecl())) {
5689 return getApproximateType(VD->getInit());
5692 if (
const auto *UO = llvm::dyn_cast<UnaryOperator>(
E)) {
5693 if (UO->getOpcode() == UnaryOperatorKind::UO_Deref) {
5696 if (
auto Pointee = getApproximateType(UO->getSubExpr())->getPointeeType();
5711 if (
auto *PLE = llvm::dyn_cast_or_null<ParenListExpr>(
Base)) {
5712 if (PLE->getNumExprs() == 0)
5714 Base = PLE->getExpr(PLE->getNumExprs() - 1);
5723 bool IsBaseExprStatement,
QualType PreferredType) {
5725 OtherOpBase = unwrapParenList(OtherOpBase);
5726 if (!
Base || !CodeCompleter)
5733 QualType ConvertedBaseType = getApproximateType(ConvertedBase.
get());
5755 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5756 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
5757 &ResultBuilder::IsMember);
5759 auto DoCompletion = [&](
Expr *
Base,
bool IsArrow,
5760 std::optional<FixItHint> AccessOpFixIt) ->
bool {
5789 RD, std::move(AccessOpFixIt));
5790 }
else if (
const auto *TTPT =
5791 dyn_cast<TemplateTypeParmType>(BaseType.
getTypePtr())) {
5793 IsArrow ? ConceptInfo::Member::Arrow : ConceptInfo::Member::Dot;
5794 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
5795 if (R.Operator != Operator)
5798 R.render(SemaRef, CodeCompleter->getAllocator(),
5799 CodeCompleter->getCodeCompletionTUInfo()));
5801 Result.FixIts.push_back(*AccessOpFixIt);
5802 Results.AddResult(std::move(
Result));
5808 if (AccessOpFixIt) {
5816 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
5819 AddedProperties, Results, IsBaseExprStatement);
5825 SemaRef.
CurContext, AddedProperties, Results,
5826 IsBaseExprStatement,
false,
5833 if (AccessOpFixIt) {
5839 Class = ObjCPtr->getInterfaceDecl();
5845 CodeCompletionDeclConsumer Consumer(Results,
Class, BaseType);
5846 Results.setFilter(&ResultBuilder::IsObjCIvar);
5848 CodeCompleter->includeGlobals(),
5850 CodeCompleter->loadExternal());
5858 Results.EnterNewScope();
5860 bool CompletionSucceded = DoCompletion(
Base, IsArrow, std::nullopt);
5861 if (CodeCompleter->includeFixIts()) {
5864 CompletionSucceded |= DoCompletion(
5865 OtherOpBase, !IsArrow,
5869 Results.ExitScope();
5871 if (!CompletionSucceded)
5876 Results.getCompletionContext(), Results.data(),
5882 bool IsBaseExprStatement) {
5890 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5891 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
5892 &ResultBuilder::IsMember);
5893 Results.EnterNewScope();
5897 AddedProperties, Results, IsBaseExprStatement,
5899 Results.ExitScope();
5901 Results.getCompletionContext(), Results.data(),
5909 ResultBuilder::LookupFilter Filter =
nullptr;
5914 Filter = &ResultBuilder::IsEnum;
5919 Filter = &ResultBuilder::IsUnion;
5926 Filter = &ResultBuilder::IsClassOrStruct;
5931 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
5934 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5935 CodeCompleter->getCodeCompletionTUInfo(), ContextKind);
5936 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
5939 Results.setFilter(Filter);
5941 CodeCompleter->includeGlobals(),
5942 CodeCompleter->loadExternal());
5944 if (CodeCompleter->includeGlobals()) {
5946 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
5948 CodeCompleter->includeGlobals(),
5949 CodeCompleter->loadExternal());
5953 Results.getCompletionContext(), Results.data(),
5960 Results.AddResult(
"const");
5962 Results.AddResult(
"volatile");
5964 Results.AddResult(
"restrict");
5966 Results.AddResult(
"_Atomic");
5968 Results.AddResult(
"__unaligned");
5972 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5973 CodeCompleter->getCodeCompletionTUInfo(),
5975 Results.EnterNewScope();
5977 Results.ExitScope();
5979 Results.getCompletionContext(), Results.data(),
5985 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5986 CodeCompleter->getCodeCompletionTUInfo(),
5988 Results.EnterNewScope();
5991 Results.AddResult(
"noexcept");
5993 !
D.isStaticMember()) {
5995 Results.AddResult(
"final");
5997 Results.AddResult(
"override");
6000 Results.ExitScope();
6002 Results.getCompletionContext(), Results.data(),
6007 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
6020 if (!
type->isEnumeralType()) {
6022 Data.IntegralConstantExpression =
true;
6023 CodeCompleteExpression(S,
Data);
6037 CoveredEnumerators Enumerators;
6039 SC = SC->getNextSwitchCase()) {
6040 CaseStmt *Case = dyn_cast<CaseStmt>(SC);
6045 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
6046 if (
auto *Enumerator =
6047 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
6054 Enumerators.Seen.insert(Enumerator);
6067 Enumerators.SuggestedQualifier = DRE->getQualifier();
6072 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6073 CodeCompleter->getCodeCompletionTUInfo(),
6078 if (CodeCompleter->includeMacros()) {
6082 Results.getCompletionContext(), Results.data(),
6087 if (Args.size() && !Args.data())
6090 for (
unsigned I = 0; I != Args.size(); ++I)
6111 if (Candidate.Function) {
6112 if (Candidate.Function->isDeleted())
6115 Candidate.Function) &&
6116 Candidate.Function->getNumParams() <= ArgSize &&
6125 if (Candidate.Viable)
6139 for (
auto &Candidate : Candidates) {
6140 QualType CandidateParamType = Candidate.getParamType(N);
6141 if (CandidateParamType.
isNull())
6143 if (ParamType.
isNull()) {
6144 ParamType = CandidateParamType;
6161 if (Candidates.empty())
6165 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc,
6176 if (
const auto *
T = Fn->getType().getTypePtr()->getAs<
TypedefType>()) {
6177 Target =
T->getDecl()->getTypeSourceInfo()->getTypeLoc();
6179 }
else if (
const auto *DR = dyn_cast<DeclRefExpr>(Fn)) {
6180 const auto *
D = DR->getDecl();
6181 if (
const auto *
const VD = dyn_cast<VarDecl>(
D)) {
6182 Target = VD->getTypeSourceInfo()->getTypeLoc();
6184 }
else if (
const auto *ME = dyn_cast<MemberExpr>(Fn)) {
6185 const auto *MD = ME->getMemberDecl();
6186 if (
const auto *FD = dyn_cast<FieldDecl>(MD)) {
6187 Target = FD->getTypeSourceInfo()->getTypeLoc();
6201 Target = A.getModifiedLoc();
6221 Fn = unwrapParenList(Fn);
6222 if (!CodeCompleter || !Fn)
6232 auto ArgsWithoutDependentTypes =
6237 Expr *NakedFn = Fn->IgnoreParenCasts();
6242 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
6246 }
else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
6248 if (UME->hasExplicitTemplateArgs()) {
6249 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
6250 TemplateArgs = &TemplateArgsBuffer;
6255 1, UME->isImplicitAccess() ?
nullptr : UME->getBase());
6256 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6257 ArgsWithoutDependentTypes.end());
6259 Decls.
append(UME->decls_begin(), UME->decls_end());
6260 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
6264 FirstArgumentIsBase);
6267 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
6268 FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl());
6269 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
6270 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
6278 ArgsWithoutDependentTypes, CandidateSet,
6288 getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
6293 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6294 ArgsWithoutDependentTypes.end());
6312 ArgsWithoutDependentTypes.size(),
6348static std::optional<unsigned>
6351 static constexpr unsigned Invalid = std::numeric_limits<unsigned>::max();
6357 unsigned ArgsAfterDesignator = 0;
6358 for (
const Expr *Arg : Args) {
6359 if (
const auto *DIE = dyn_cast<DesignatedInitExpr>(Arg)) {
6360 if (DIE->size() == 1 && DIE->getDesignator(0)->isFieldDesignator()) {
6361 DesignatedFieldName = DIE->getDesignator(0)->getFieldName();
6362 ArgsAfterDesignator = 0;
6366 }
else if (isa<DesignatedInitUpdateExpr>(Arg)) {
6369 ++ArgsAfterDesignator;
6372 if (!DesignatedFieldName)
6373 return std::nullopt;
6377 unsigned DesignatedIndex = 0;
6378 const FieldDecl *DesignatedField =
nullptr;
6379 for (
const auto *Field :
Aggregate.getAggregate()->fields()) {
6380 if (Field->getIdentifier() == DesignatedFieldName) {
6381 DesignatedField = Field;
6386 if (!DesignatedField)
6390 unsigned AggregateSize =
Aggregate.getNumParams();
6391 while (DesignatedIndex < AggregateSize &&
6392 Aggregate.getParamDecl(DesignatedIndex) != DesignatedField)
6396 return DesignatedIndex + ArgsAfterDesignator + 1;
6419 if (Braced && !RD->
isUnion() &&
6424 if (
auto NextIndex =
6427 if (*NextIndex >= AggregateSize)
6429 Results.push_back(AggregateSig);
6435 if (Args.size() < AggregateSize)
6436 Results.push_back(AggregateSig);
6445 if (
auto *FD = dyn_cast<FunctionDecl>(
C)) {
6448 if (Braced && getLangOpts().
CPlusPlus &&
6456 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
6457 if (Braced && getLangOpts().
CPlusPlus &&
6463 nullptr, Args, CandidateSet,
6484 dyn_cast<CXXConstructorDecl>(ConstructorDecl);
6489 Constructor->getParent(), SS, TemplateTypeTy, II))
6490 return ProduceConstructorSignatureHelp(MemberDecl->getType(),
6491 MemberDecl->getLocation(), ArgExprs,
6492 OpenParLoc, Braced);
6500 if (Index < Params.
size())
6503 Param = Params.
asArray().back();
6509 return llvm::isa<TemplateTypeParmDecl>(Param);
6511 return llvm::isa<NonTypeTemplateParmDecl>(Param);
6513 return llvm::isa<TemplateTemplateParmDecl>(Param);
6515 llvm_unreachable(
"Unhandled switch case");
6521 if (!CodeCompleter || !ParsedTemplate)
6527 bool Matches =
true;
6528 for (
unsigned I = 0; I < Args.size(); ++I) {
6535 Results.emplace_back(TD);
6543 if (
const auto *TD = llvm::dyn_cast<TemplateDecl>(ND))
6556 if (
D.isArrayDesignator() ||
D.isArrayRangeDesignator()) {
6560 assert(
D.isFieldDesignator());
6562 if (RD && RD->isCompleteDefinition()) {
6563 for (
const auto *
Member : RD->lookup(
D.getFieldDecl()))
6565 NextType = FD->getType();
6570 BaseType = NextType;
6581 if (!RD || RD->fields().empty())
6586 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6587 CodeCompleter->getCodeCompletionTUInfo(), CCC);
6589 Results.EnterNewScope();
6590 for (
const Decl *
D : RD->decls()) {
6592 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(
D))
6593 FD = IFD->getAnonField();
6594 else if (
auto *DFD = dyn_cast<FieldDecl>(
D))
6604 Results.ExitScope();
6606 Results.getCompletionContext(), Results.data(),
6611 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(
D);
6613 CodeCompleteOrdinaryName(S, PCC_Expression);
6620 Data.IgnoreDecls.push_back(VD);
6622 CodeCompleteExpression(S,
Data);
6626 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6627 CodeCompleter->getCodeCompletionTUInfo(),
6629 Results.setFilter(&ResultBuilder::IsOrdinaryName);
6630 Results.EnterNewScope();
6632 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6634 CodeCompleter->includeGlobals(),
6635 CodeCompleter->loadExternal());
6641 Results.getCodeCompletionTUInfo());
6643 auto AddElseBodyPattern = [&] {
6648 Builder.AddPlaceholderChunk(
"statements");
6654 Builder.AddPlaceholderChunk(
"statement");
6658 Builder.AddTypedTextChunk(
"else");
6659 if (Results.includeCodePatterns())
6660 AddElseBodyPattern();
6661 Results.AddResult(Builder.TakeString());
6664 Builder.AddTypedTextChunk(
"else if");
6668 Builder.AddPlaceholderChunk(
"condition");
6670 Builder.AddPlaceholderChunk(
"expression");
6672 if (Results.includeCodePatterns()) {
6673 AddElseBodyPattern();
6675 Results.AddResult(Builder.TakeString());
6677 Results.ExitScope();
6679 if (S->getFnParent())
6682 if (CodeCompleter->includeMacros())
6686 Results.getCompletionContext(), Results.data(),
6691 bool EnteringContext,
6692 bool IsUsingDeclaration,
6695 if (SS.
isEmpty() || !CodeCompleter)
6710 ResultBuilder DummyResults(SemaRef, CodeCompleter->getAllocator(),
6711 CodeCompleter->getCodeCompletionTUInfo(), CC);
6712 if (!PreferredType.
isNull())
6713 DummyResults.setPreferredType(PreferredType);
6714 if (S->getEntity()) {
6715 CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
6722 DummyResults.getCompletionContext(),
nullptr, 0);
6737 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6738 CodeCompleter->getCodeCompletionTUInfo(), CC);
6739 if (!PreferredType.
isNull())
6740 Results.setPreferredType(PreferredType);
6741 Results.EnterNewScope();
6746 if (!Results.empty() && NNS && NNS->
isDependent())
6747 Results.AddResult(
"template");
6752 if (
const auto *TTPT =
6753 dyn_cast_or_null<TemplateTypeParmType>(NNS->
getAsType())) {
6754 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
6755 if (R.Operator != ConceptInfo::Member::Colons)
6758 R.render(SemaRef, CodeCompleter->getAllocator(),
6759 CodeCompleter->getCodeCompletionTUInfo())));
6769 if (Ctx && !EnteringContext)
6771 Results.ExitScope();
6774 (CodeCompleter->includeNamespaceLevelDecls() || !Ctx->
isFileContext())) {
6775 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
6779 CodeCompleter->loadExternal());
6783 Results.getCompletionContext(), Results.data(),
6794 Context.setIsUsingDeclaration(
true);
6796 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6797 CodeCompleter->getCodeCompletionTUInfo(), Context,
6798 &ResultBuilder::IsNestedNameSpecifier);
6799 Results.EnterNewScope();
6802 if (!S->isClassScope())
6807 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6809 CodeCompleter->includeGlobals(),
6810 CodeCompleter->loadExternal());
6811 Results.ExitScope();
6814 Results.getCompletionContext(), Results.data(),
6824 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6825 CodeCompleter->getCodeCompletionTUInfo(),
6827 &ResultBuilder::IsNamespaceOrAlias);
6828 Results.EnterNewScope();
6829 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6831 CodeCompleter->includeGlobals(),
6832 CodeCompleter->loadExternal());
6833 Results.ExitScope();
6835 Results.getCompletionContext(), Results.data(),
6844 if (!S->getParent())
6845 Ctx = getASTContext().getTranslationUnitDecl();
6847 bool SuppressedGlobalResults =
6848 Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
6850 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6851 CodeCompleter->getCodeCompletionTUInfo(),
6852 SuppressedGlobalResults
6855 &ResultBuilder::IsNamespace);
6857 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
6862 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
6867 OrigToLatest[NS->getFirstDecl()] = *NS;
6871 Results.EnterNewScope();
6872 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
6873 NS = OrigToLatest.begin(),
6874 NSEnd = OrigToLatest.end();
6880 Results.ExitScope();
6884 Results.getCompletionContext(), Results.data(),
6893 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6894 CodeCompleter->getCodeCompletionTUInfo(),
6896 &ResultBuilder::IsNamespaceOrAlias);
6897 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6899 CodeCompleter->includeGlobals(),
6900 CodeCompleter->loadExternal());
6902 Results.getCompletionContext(), Results.data(),
6911 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6912 CodeCompleter->getCodeCompletionTUInfo(),
6914 &ResultBuilder::IsType);
6915 Results.EnterNewScope();
6919#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
6920 if (OO_##Name != OO_Conditional) \
6921 Results.AddResult(Result(Spelling));
6922#include "clang/Basic/OperatorKinds.def"
6925 Results.allowNestedNameSpecifiers();
6926 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6928 CodeCompleter->includeGlobals(),
6929 CodeCompleter->loadExternal());
6933 Results.ExitScope();
6936 Results.getCompletionContext(), Results.data(),
6947 auto *Constructor = dyn_cast<CXXConstructorDecl>(ConstructorD);
6951 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6952 CodeCompleter->getCodeCompletionTUInfo(),
6954 Results.EnterNewScope();
6959 for (
unsigned I = 0,
E = Initializers.size(); I !=
E; ++I) {
6960 if (Initializers[I]->isBaseInitializer())
6961 InitializedBases.insert(getASTContext().getCanonicalType(
6962 QualType(Initializers[I]->getBaseClass(), 0)));
6964 InitializedFields.insert(
6965 cast<FieldDecl>(Initializers[I]->getAnyMember()));
6970 bool SawLastInitializer = Initializers.empty();
6973 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
6975 Results.getCodeCompletionTUInfo());
6976 Builder.AddTypedTextChunk(Name);
6978 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND))
6980 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
6982 FunTemplDecl->getTemplatedDecl(), Builder);
6984 return Builder.TakeString();
6986 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
6989 Results.getCodeCompletionTUInfo());
6990 Builder.AddTypedTextChunk(Name);
6992 Builder.AddPlaceholderChunk(
Type);
6996 Builder.TakeString(), ND,
6998 if (isa<FieldDecl>(ND))
7000 return Results.AddResult(CCR);
7003 Builder.TakeString(),
7007 const char *Name,
const FieldDecl *FD) {
7009 return AddDefaultCtorInit(Name,
7010 FD ? Results.getAllocator().CopyString(
7011 FD->getType().getAsString(Policy))
7015 if (Ctors.begin() == Ctors.end())
7016 return AddDefaultCtorInit(Name, Name, RD);
7020 Results.AddResult(CCR);
7024 const char *BaseName =
7025 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
7026 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
7031 auto AddField = [&](
const FieldDecl *FD) {
7032 const char *FieldName =
7033 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
7034 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
7040 for (
const auto &
Base : ClassDecl->
bases()) {
7041 if (!InitializedBases
7042 .insert(getASTContext().getCanonicalType(
Base.getType()))
7044 SawLastInitializer =
7045 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7046 getASTContext().hasSameUnqualifiedType(
7047 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7052 SawLastInitializer =
false;
7056 for (
const auto &
Base : ClassDecl->
vbases()) {
7057 if (!InitializedBases
7058 .insert(getASTContext().getCanonicalType(
Base.getType()))
7060 SawLastInitializer =
7061 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7062 getASTContext().hasSameUnqualifiedType(
7063 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7068 SawLastInitializer =
false;
7072 for (
auto *Field : ClassDecl->
fields()) {
7073 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
7075 SawLastInitializer = !Initializers.empty() &&
7076 Initializers.back()->isAnyMemberInitializer() &&
7077 Initializers.back()->getAnyMember() == Field;
7081 if (!Field->getDeclName())
7085 SawLastInitializer =
false;
7087 Results.ExitScope();
7090 Results.getCompletionContext(), Results.data(),
7105 bool AfterAmpersand) {
7106 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7107 CodeCompleter->getCodeCompletionTUInfo(),
7109 Results.EnterNewScope();
7113 bool IncludedThis =
false;
7116 IncludedThis =
true;
7125 for (
const auto *
D : S->decls()) {
7126 const auto *Var = dyn_cast<VarDecl>(
D);
7127 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
7130 if (Known.insert(Var->getIdentifier()).second)
7140 Results.ExitScope();
7143 Results.getCompletionContext(), Results.data(),
7150 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7151 CodeCompleter->getCodeCompletionTUInfo(),
7153 auto ShouldAddDefault = [&
D,
this]() {
7154 if (!
D.isFunctionDeclarator())
7156 auto &
Id =
D.getName();
7162 D.getFunctionTypeInfo().NumParams <= 1)
7165 auto Op =
Id.OperatorFunctionId.Operator;
7168 if (Op == OverloadedOperatorKind::OO_Equal)
7170 if (getLangOpts().CPlusPlus20 &&
7171 (Op == OverloadedOperatorKind::OO_EqualEqual ||
7172 Op == OverloadedOperatorKind::OO_ExclaimEqual ||
7173 Op == OverloadedOperatorKind::OO_Less ||
7174 Op == OverloadedOperatorKind::OO_LessEqual ||
7175 Op == OverloadedOperatorKind::OO_Greater ||
7176 Op == OverloadedOperatorKind::OO_GreaterEqual ||
7177 Op == OverloadedOperatorKind::OO_Spaceship))
7183 Results.EnterNewScope();
7184 if (ShouldAddDefault())
7185 Results.AddResult(
"default");
7188 Results.AddResult(
"delete");
7189 Results.ExitScope();
7191 Results.getCompletionContext(), Results.data(),
7197#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
7200 ResultBuilder &Results,
bool NeedAt) {
7206 Results.getCodeCompletionTUInfo());
7207 if (LangOpts.ObjC) {
7211 Builder.AddPlaceholderChunk(
"property");
7212 Results.AddResult(
Result(Builder.TakeString()));
7217 Builder.AddPlaceholderChunk(
"property");
7218 Results.AddResult(
Result(Builder.TakeString()));
7223 ResultBuilder &Results,
bool NeedAt) {
7229 if (LangOpts.ObjC) {
7244 Results.getCodeCompletionTUInfo());
7249 Builder.AddPlaceholderChunk(
"name");
7250 Results.AddResult(
Result(Builder.TakeString()));
7252 if (Results.includeCodePatterns()) {
7258 Builder.AddPlaceholderChunk(
"class");
7259 Results.AddResult(
Result(Builder.TakeString()));
7264 Builder.AddPlaceholderChunk(
"protocol");
7265 Results.AddResult(
Result(Builder.TakeString()));
7270 Builder.AddPlaceholderChunk(
"class");
7271 Results.AddResult(
Result(Builder.TakeString()));
7275 Builder.AddTypedTextChunk(
7278 Builder.AddPlaceholderChunk(
"alias");
7280 Builder.AddPlaceholderChunk(
"class");
7281 Results.AddResult(
Result(Builder.TakeString()));
7283 if (Results.getSema().getLangOpts().Modules) {
7287 Builder.AddPlaceholderChunk(
"module");
7288 Results.AddResult(
Result(Builder.TakeString()));
7293 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7294 CodeCompleter->getCodeCompletionTUInfo(),
7296 Results.EnterNewScope();
7303 Results.ExitScope();
7305 Results.getCompletionContext(), Results.data(),
7312 Results.getCodeCompletionTUInfo());
7315 const char *EncodeType =
"char[]";
7316 if (Results.getSema().getLangOpts().CPlusPlus ||
7317 Results.getSema().getLangOpts().ConstStrings)
7318 EncodeType =
"const char[]";
7319 Builder.AddResultTypeChunk(EncodeType);
7322 Builder.AddPlaceholderChunk(
"type-name");
7324 Results.AddResult(
Result(Builder.TakeString()));
7327 Builder.AddResultTypeChunk(
"Protocol *");
7330 Builder.AddPlaceholderChunk(
"protocol-name");
7332 Results.AddResult(
Result(Builder.TakeString()));
7335 Builder.AddResultTypeChunk(
"SEL");
7338 Builder.AddPlaceholderChunk(
"selector");
7340 Results.AddResult(
Result(Builder.TakeString()));
7343 Builder.AddResultTypeChunk(
"NSString *");
7345 Builder.AddPlaceholderChunk(
"string");
7346 Builder.AddTextChunk(
"\"");
7347 Results.AddResult(
Result(Builder.TakeString()));
7350 Builder.AddResultTypeChunk(
"NSArray *");
7352 Builder.AddPlaceholderChunk(
"objects, ...");
7354 Results.AddResult(
Result(Builder.TakeString()));
7357 Builder.AddResultTypeChunk(
"NSDictionary *");
7359 Builder.AddPlaceholderChunk(
"key");
7362 Builder.AddPlaceholderChunk(
"object, ...");
7364 Results.AddResult(
Result(Builder.TakeString()));
7367 Builder.AddResultTypeChunk(
"id");
7369 Builder.AddPlaceholderChunk(
"expression");
7371 Results.AddResult(
Result(Builder.TakeString()));
7377 Results.getCodeCompletionTUInfo());
7379 if (Results.includeCodePatterns()) {
7384 Builder.AddPlaceholderChunk(
"statements");
7386 Builder.AddTextChunk(
"@catch");
7388 Builder.AddPlaceholderChunk(
"parameter");
7391 Builder.AddPlaceholderChunk(
"statements");
7393 Builder.AddTextChunk(
"@finally");
7395 Builder.AddPlaceholderChunk(
"statements");
7397 Results.AddResult(
Result(Builder.TakeString()));
7403 Builder.AddPlaceholderChunk(
"expression");
7404 Results.AddResult(
Result(Builder.TakeString()));
7406 if (Results.includeCodePatterns()) {
7411 Builder.AddPlaceholderChunk(
"expression");
7414 Builder.AddPlaceholderChunk(
"statements");
7416 Results.AddResult(
Result(Builder.TakeString()));
7421 ResultBuilder &Results,
bool NeedAt) {
7431 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7432 CodeCompleter->getCodeCompletionTUInfo(),
7434 Results.EnterNewScope();
7436 Results.ExitScope();
7438 Results.getCompletionContext(), Results.data(),
7443 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7444 CodeCompleter->getCodeCompletionTUInfo(),
7446 Results.EnterNewScope();
7449 Results.ExitScope();
7451 Results.getCompletionContext(), Results.data(),
7456 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7457 CodeCompleter->getCodeCompletionTUInfo(),
7459 Results.EnterNewScope();
7461 Results.ExitScope();
7463 Results.getCompletionContext(), Results.data(),
7471 if (Attributes & NewFlag)
7474 Attributes |= NewFlag;
7482 unsigned AssignCopyRetMask =
7488 if (AssignCopyRetMask &&
7507 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7508 CodeCompleter->getCodeCompletionTUInfo(),
7510 Results.EnterNewScope();
7547 Results.getCodeCompletionTUInfo());
7556 Results.getCodeCompletionTUInfo());
7569 Results.ExitScope();
7571 Results.getCompletionContext(), Results.data(),
7585 bool AllowSameLength =
true) {
7586 unsigned NumSelIdents = SelIdents.size();
7599 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
7602 for (
unsigned I = 0; I != NumSelIdents; ++I)
7612 bool AllowSameLength =
true) {
7646 ResultBuilder &Results,
bool InOriginalClass =
true,
7647 bool IsRootClass =
false) {
7651 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
7655 if (M->isInstanceMethod() == WantInstanceMethods ||
7656 (IsRootClass && !WantInstanceMethods)) {
7662 if (!Selectors.insert(M->getSelector()).second)
7665 Result R =
Result(M, Results.getBasePriority(M),
nullptr);
7666 R.StartParameter = SelIdents.size();
7667 R.AllParametersAreInformative = (WantKind !=
MK_Any);
7668 if (!InOriginalClass)
7670 Results.MaybeAddResult(R, CurContext);
7675 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
7676 if (Protocol->hasDefinition()) {
7678 Protocol->getReferencedProtocols();
7680 E = Protocols.
end();
7682 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7683 Selectors, AllowSameLength, Results,
false, IsRootClass);
7692 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7693 Selectors, AllowSameLength, Results,
false, IsRootClass);
7697 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
7698 CurContext, Selectors, AllowSameLength, Results,
7699 InOriginalClass, IsRootClass);
7703 CatDecl->getReferencedProtocols();
7705 E = Protocols.
end();
7707 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7708 Selectors, AllowSameLength, Results,
false, IsRootClass);
7712 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7713 Selectors, AllowSameLength, Results, InOriginalClass,
7721 SelIdents, CurContext, Selectors, AllowSameLength, Results,
7726 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7727 Selectors, AllowSameLength, Results, InOriginalClass,
7734 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7737 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7745 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7746 CodeCompleter->getCodeCompletionTUInfo(),
7748 Results.EnterNewScope();
7754 Results.ExitScope();
7756 Results.getCompletionContext(), Results.data(),
7763 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7766 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7774 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7775 CodeCompleter->getCodeCompletionTUInfo(),
7777 Results.EnterNewScope();
7784 Results.ExitScope();
7786 Results.getCompletionContext(), Results.data(),
7792 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7793 CodeCompleter->getCodeCompletionTUInfo(),
7795 Results.EnterNewScope();
7798 bool AddedInOut =
false;
7801 Results.AddResult(
"in");
7802 Results.AddResult(
"inout");
7807 Results.AddResult(
"out");
7809 Results.AddResult(
"inout");
7814 Results.AddResult(
"bycopy");
7815 Results.AddResult(
"byref");
7816 Results.AddResult(
"oneway");
7819 Results.AddResult(
"nonnull");
7820 Results.AddResult(
"nullable");
7821 Results.AddResult(
"null_unspecified");
7831 Results.getCodeCompletionTUInfo(),
7833 Builder.AddTypedTextChunk(
"IBAction");
7835 Builder.AddPlaceholderChunk(
"selector");
7838 Builder.AddTextChunk(
"id");
7840 Builder.AddTextChunk(
"sender");
7851 Results.ExitScope();
7854 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
7855 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7857 CodeCompleter->includeGlobals(),
7858 CodeCompleter->loadExternal());
7860 if (CodeCompleter->includeMacros())
7864 Results.getCompletionContext(), Results.data(),
7873 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(
E);
7891 switch (Msg->getReceiverKind()) {
7895 IFace = ObjType->getInterface();
7899 QualType T = Msg->getInstanceReceiver()->getType();
7901 IFace = Ptr->getInterfaceDecl();
7915 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
7916 .Case(
"retain", IFace)
7917 .Case(
"strong", IFace)
7918 .Case(
"autorelease", IFace)
7919 .Case(
"copy", IFace)
7920 .Case(
"copyWithZone", IFace)
7921 .Case(
"mutableCopy", IFace)
7922 .Case(
"mutableCopyWithZone", IFace)
7923 .Case(
"awakeFromCoder", IFace)
7924 .Case(
"replacementObjectFromCoder", IFace)
7925 .Case(
"class", IFace)
7926 .Case(
"classForCoder", IFace)
7927 .Case(
"superclass", Super)
7930 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
7932 .Case(
"alloc", IFace)
7933 .Case(
"allocWithZone", IFace)
7934 .Case(
"class", IFace)
7935 .Case(
"superclass", Super)
7958 ResultBuilder &Results) {
7969 while ((
Class =
Class->getSuperClass()) && !SuperMethod) {
7976 for (
const auto *Cat :
Class->known_categories()) {
7977 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
7995 CurP != CurPEnd; ++CurP, ++SuperP) {
7998 (*SuperP)->getType()))
8002 if (!(*CurP)->getIdentifier())
8008 Results.getCodeCompletionTUInfo());
8012 Results.getCompletionContext().getBaseType(), Builder);
8015 if (NeedSuperKeyword) {
8016 Builder.AddTypedTextChunk(
"super");
8022 if (NeedSuperKeyword)
8023 Builder.AddTextChunk(
8026 Builder.AddTypedTextChunk(
8030 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
8031 if (I > SelIdents.size())
8034 if (I < SelIdents.size())
8035 Builder.AddInformativeChunk(
8037 else if (NeedSuperKeyword || I > SelIdents.size()) {
8038 Builder.AddTextChunk(
8040 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8041 (*CurP)->getIdentifier()->getName()));
8043 Builder.AddTypedTextChunk(
8045 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8046 (*CurP)->getIdentifier()->getName()));
8058 ResultBuilder Results(
8059 SemaRef, CodeCompleter->getAllocator(),
8060 CodeCompleter->getCodeCompletionTUInfo(),
8063 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
8064 : &ResultBuilder::IsObjCMessageReceiver);
8066 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
8067 Results.EnterNewScope();
8069 CodeCompleter->includeGlobals(),
8070 CodeCompleter->loadExternal());
8076 if (Iface->getSuperClass()) {
8077 Results.AddResult(
Result(
"super"));
8086 Results.ExitScope();
8088 if (CodeCompleter->includeMacros())
8091 Results.getCompletionContext(), Results.data(),
8101 CDecl = CurMethod->getClassInterface();
8110 if (CurMethod->isInstanceMethod()) {
8114 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
8115 AtArgumentExpression, CDecl);
8125 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
8127 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
8129 getASTContext().getTypeDeclType(TD)->getAs<ObjCObjectType>())
8130 CDecl = Iface->getInterface();
8131 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
8143 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
8144 SelIdents, AtArgumentExpression);
8153 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
8154 AtArgumentExpression,
8161 unsigned NumSelIdents) {
8163 ASTContext &Context = Results.getSema().Context;
8167 Result *ResultsData = Results.data();
8168 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
8169 Result &R = ResultsData[I];
8170 if (R.Kind == Result::RK_Declaration &&
8171 isa<ObjCMethodDecl>(R.Declaration)) {
8172 if (R.Priority <= BestPriority) {
8173 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
8174 if (NumSelIdents <= Method->param_size()) {
8176 Method->
parameters()[NumSelIdents - 1]->getType();
8177 if (R.Priority < BestPriority || PreferredType.
isNull()) {
8178 BestPriority = R.Priority;
8179 PreferredType = MyPreferredType;
8189 return PreferredType;
8195 bool AtArgumentExpression,
bool IsSuper,
8196 ResultBuilder &Results) {
8211 Results.EnterNewScope();
8218 Results.Ignore(SuperMethod);
8224 Results.setPreferredSelector(CurMethod->getSelector());
8229 Selectors, AtArgumentExpression, Results);
8236 for (uint32_t I = 0,
8252 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8256 Result R(MethList->getMethod(),
8257 Results.getBasePriority(MethList->getMethod()),
nullptr);
8258 R.StartParameter = SelIdents.size();
8259 R.AllParametersAreInformative =
false;
8260 Results.MaybeAddResult(R, SemaRef.
CurContext);
8265 Results.ExitScope();
8270 bool AtArgumentExpression,
bool IsSuper) {
8274 ResultBuilder Results(
8275 SemaRef, CodeCompleter->getAllocator(),
8276 CodeCompleter->getCodeCompletionTUInfo(),
8281 AtArgumentExpression, IsSuper, Results);
8288 if (AtArgumentExpression) {
8291 if (PreferredType.
isNull())
8292 CodeCompleteOrdinaryName(S, PCC_Expression);
8294 CodeCompleteExpression(S, PreferredType);
8299 Results.getCompletionContext(), Results.data(),
8309 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
8317 RecExpr = Conv.
get();
8331 return CodeCompleteObjCClassMessage(
8333 AtArgumentExpression, Super);
8338 }
else if (RecExpr && getLangOpts().CPlusPlus) {
8341 RecExpr = Conv.
get();
8342 ReceiverType = RecExpr->
getType();
8347 ResultBuilder Results(
8348 SemaRef, CodeCompleter->getAllocator(),
8349 CodeCompleter->getCodeCompletionTUInfo(),
8351 ReceiverType, SelIdents));
8353 Results.EnterNewScope();
8360 Results.Ignore(SuperMethod);
8366 Results.setPreferredSelector(CurMethod->getSelector());
8379 Selectors, AtArgumentExpression, Results);
8386 for (
auto *I : QualID->quals())
8388 AtArgumentExpression, Results);
8395 SemaRef.
CurContext, Selectors, AtArgumentExpression,
8399 for (
auto *I : IFacePtr->quals())
8401 AtArgumentExpression, Results);
8411 for (uint32_t I = 0,
8427 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8431 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
8434 Result R(MethList->getMethod(),
8435 Results.getBasePriority(MethList->getMethod()),
nullptr);
8436 R.StartParameter = SelIdents.size();
8437 R.AllParametersAreInformative =
false;
8438 Results.MaybeAddResult(R, SemaRef.
CurContext);
8442 Results.ExitScope();
8449 if (AtArgumentExpression) {
8452 if (PreferredType.
isNull())
8453 CodeCompleteOrdinaryName(S, PCC_Expression);
8455 CodeCompleteExpression(S, PreferredType);
8460 Results.getCompletionContext(), Results.data(),
8467 Data.ObjCCollection =
true;
8473 Data.IgnoreDecls.push_back(*I);
8477 CodeCompleteExpression(S,
Data);
8485 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
8495 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8496 CodeCompleter->getCodeCompletionTUInfo(),
8498 Results.EnterNewScope();
8509 Results.getCodeCompletionTUInfo());
8511 Builder.AddTypedTextChunk(
8513 Results.AddResult(Builder.TakeString());
8517 std::string Accumulator;
8518 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
8519 if (I == SelIdents.size()) {
8520 if (!Accumulator.empty()) {
8521 Builder.AddInformativeChunk(
8522 Builder.getAllocator().CopyString(Accumulator));
8523 Accumulator.clear();
8530 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
8531 Results.AddResult(Builder.TakeString());
8533 Results.ExitScope();
8536 Results.getCompletionContext(), Results.data(),
8543 bool OnlyForwardDeclarations,
8544 ResultBuilder &Results) {
8547 for (
const auto *
D : Ctx->
decls()) {
8549 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(
D))
8550 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
8552 Result(Proto, Results.getBasePriority(Proto),
nullptr), CurContext,
8559 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8560 CodeCompleter->getCodeCompletionTUInfo(),
8563 if (CodeCompleter->includeGlobals()) {
8564 Results.EnterNewScope();
8572 Results.Ignore(Protocol);
8578 Results.ExitScope();
8582 Results.getCompletionContext(), Results.data(),
8587 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8588 CodeCompleter->getCodeCompletionTUInfo(),
8591 if (CodeCompleter->includeGlobals()) {
8592 Results.EnterNewScope();
8598 Results.ExitScope();
8602 Results.getCompletionContext(), Results.data(),
8609 bool OnlyForwardDeclarations,
8610 bool OnlyUnimplemented,
8611 ResultBuilder &Results) {
8614 for (
const auto *
D : Ctx->
decls()) {
8616 if (
const auto *
Class = dyn_cast<ObjCInterfaceDecl>(
D))
8617 if ((!OnlyForwardDeclarations || !
Class->hasDefinition()) &&
8618 (!OnlyUnimplemented || !
Class->getImplementation()))
8626 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8627 CodeCompleter->getCodeCompletionTUInfo(),
8629 Results.EnterNewScope();
8631 if (CodeCompleter->includeGlobals()) {
8637 Results.ExitScope();
8640 Results.getCompletionContext(), Results.data(),
8645 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8646 CodeCompleter->getCodeCompletionTUInfo(),
8648 Results.EnterNewScope();
8650 if (CodeCompleter->includeGlobals()) {
8656 Results.ExitScope();
8659 Results.getCompletionContext(), Results.data(),
8665 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8666 CodeCompleter->getCodeCompletionTUInfo(),
8668 Results.EnterNewScope();
8673 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
8674 Results.Ignore(CurClass);
8676 if (CodeCompleter->includeGlobals()) {
8682 Results.ExitScope();
8685 Results.getCompletionContext(), Results.data(),
8690 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8691 CodeCompleter->getCodeCompletionTUInfo(),
8693 Results.EnterNewScope();
8695 if (CodeCompleter->includeGlobals()) {
8701 Results.ExitScope();
8704 Results.getCompletionContext(), Results.data(),
8712 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8713 CodeCompleter->getCodeCompletionTUInfo(),
8722 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
8723 for (
const auto *Cat :
Class->visible_categories())
8724 CategoryNames.insert(Cat->getIdentifier());
8728 Results.EnterNewScope();
8730 for (
const auto *
D : TU->
decls())
8731 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(
D))
8732 if (CategoryNames.insert(
Category->getIdentifier()).second)
8736 Results.ExitScope();
8739 Results.getCompletionContext(), Results.data(),
8754 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
8756 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8757 CodeCompleter->getCodeCompletionTUInfo(),
8764 Results.EnterNewScope();
8765 bool IgnoreImplemented =
true;
8767 for (
const auto *Cat :
Class->visible_categories()) {
8768 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
8769 CategoryNames.insert(Cat->getIdentifier()).second)
8770 Results.AddResult(
Result(Cat, Results.getBasePriority(Cat),
nullptr),
8775 IgnoreImplemented =
false;
8777 Results.ExitScope();
8780 Results.getCompletionContext(), Results.data(),
8786 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8787 CodeCompleter->getCodeCompletionTUInfo(), CCContext);
8791 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8792 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8793 !isa<ObjCCategoryImplDecl>(Container)))
8798 for (
const auto *
D : Container->decls())
8799 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(
D))
8800 Results.Ignore(PropertyImpl->getPropertyDecl());
8804 Results.EnterNewScope();
8806 dyn_cast<ObjCImplementationDecl>(Container))
8809 AddedProperties, Results);
8812 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
8814 AddedProperties, Results);
8815 Results.ExitScope();
8818 Results.getCompletionContext(), Results.data(),
8825 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8826 CodeCompleter->getCodeCompletionTUInfo(),
8831 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8832 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8833 !isa<ObjCCategoryImplDecl>(Container)))
8839 dyn_cast<ObjCImplementationDecl>(Container))
8840 Class = ClassImpl->getClassInterface();
8842 Class = cast<ObjCCategoryImplDecl>(Container)
8844 ->getClassInterface();
8847 QualType PropertyType = getASTContext().getObjCIdType();
8852 Property->getType().getNonReferenceType().getUnqualifiedType();
8855 Results.setPreferredType(PropertyType);
8860 Results.EnterNewScope();
8861 bool SawSimilarlyNamedIvar =
false;
8862 std::string NameWithPrefix;
8863 NameWithPrefix +=
'_';
8864 NameWithPrefix += PropertyName->getName();
8865 std::string NameWithSuffix = PropertyName->getName().str();
8866 NameWithSuffix +=
'_';
8869 Ivar = Ivar->getNextIvar()) {
8870 Results.AddResult(
Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
8875 if ((PropertyName == Ivar->getIdentifier() ||
8876 NameWithPrefix == Ivar->getName() ||
8877 NameWithSuffix == Ivar->getName())) {
8878 SawSimilarlyNamedIvar =
true;
8882 if (Results.size() &&
8883 Results.data()[Results.size() - 1].Kind ==
8885 Results.data()[Results.size() - 1].Declaration == Ivar)
8886 Results.data()[Results.size() - 1].Priority--;
8891 if (!SawSimilarlyNamedIvar) {
8902 PropertyType, getASTContext(), Policy, Allocator));
8903 Builder.AddTypedTextChunk(Allocator.CopyString(NameWithPrefix));
8908 Results.ExitScope();
8911 Results.getCompletionContext(), Results.data(),
8918 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
8927 std::optional<bool> WantInstanceMethods,
8930 bool InOriginalClass =
true) {
8933 if (!IFace->hasDefinition())
8936 IFace = IFace->getDefinition();
8940 IFace->getReferencedProtocols();
8942 E = Protocols.
end();
8945 KnownMethods, InOriginalClass);
8948 for (
auto *Cat : IFace->visible_categories()) {
8950 KnownMethods,
false);
8954 if (IFace->getSuperClass())
8956 WantInstanceMethods, ReturnType, KnownMethods,
8963 Category->getReferencedProtocols();
8965 E = Protocols.
end();
8968 KnownMethods, InOriginalClass);
8971 if (InOriginalClass &&
Category->getClassInterface())
8973 WantInstanceMethods, ReturnType, KnownMethods,
8979 if (!Protocol->hasDefinition())
8981 Protocol = Protocol->getDefinition();
8982 Container = Protocol;
8986 Protocol->getReferencedProtocols();
8988 E = Protocols.
end();
8991 KnownMethods,
false);
8997 for (
auto *M : Container->methods()) {
8998 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
8999 if (!ReturnType.
isNull() &&
9003 KnownMethods[M->getSelector()] =
9004 KnownMethodsMap::mapped_type(M, InOriginalClass);
9018 Builder.AddTextChunk(Builder.getAllocator().CopyString(Quals));
9019 Builder.AddTextChunk(
9030 if (
Class->getIdentifier() &&
Class->getIdentifier()->getName() == Name)
9039 bool IsInstanceMethod,
9042 ResultBuilder &Results) {
9044 if (!PropName || PropName->
getLength() == 0)
9062 const char *CopiedKey;
9065 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
9067 operator const char *() {
9071 return CopiedKey = Allocator.CopyString(Key);
9073 } Key(Allocator, PropName->
getName());
9076 std::string UpperKey = std::string(PropName->
getName());
9077 if (!UpperKey.empty())
9080 bool ReturnTypeMatchesProperty =
9084 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
9087 if (IsInstanceMethod &&
9089 ReturnTypeMatchesProperty && !
Property->getGetterMethodDecl()) {
9094 Builder.AddTypedTextChunk(Key);
9101 if (IsInstanceMethod &&
9102 ((!ReturnType.
isNull() &&
9105 Property->getType()->isBooleanType())))) {
9106 std::string SelectorName = (Twine(
"is") + UpperKey).str();
9110 if (ReturnType.
isNull()) {
9112 Builder.AddTextChunk(
"BOOL");
9116 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9123 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
9124 !
Property->getSetterMethodDecl()) {
9125 std::string SelectorName = (Twine(
"set") + UpperKey).str();
9127 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9128 if (ReturnType.
isNull()) {
9130 Builder.AddTextChunk(
"void");
9134 Builder.AddTypedTextChunk(
9135 Allocator.CopyString(SelectorId->
getName() +
":"));
9138 Builder.AddTextChunk(Key);
9149 if (
const auto *ObjCPointer =
9174 if (IsInstanceMethod &&
9176 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
9180 if (ReturnType.
isNull()) {
9182 Builder.AddTextChunk(
"NSUInteger");
9186 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9188 Result(Builder.TakeString(),
9189 std::min(IndexedGetterPriority, UnorderedGetterPriority),
9196 if (IsInstanceMethod &&
9198 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
9200 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9201 if (ReturnType.
isNull()) {
9203 Builder.AddTextChunk(
"id");
9207 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9209 Builder.AddTextChunk(
"NSUInteger");
9211 Builder.AddTextChunk(
"index");
9212 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9218 if (IsInstanceMethod &&
9225 std::string SelectorName = (Twine(
Property->getName()) +
"AtIndexes").str();
9227 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9228 if (ReturnType.
isNull()) {
9230 Builder.AddTextChunk(
"NSArray *");
9234 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9236 Builder.AddTextChunk(
"NSIndexSet *");
9238 Builder.AddTextChunk(
"indexes");
9239 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9245 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9246 std::string SelectorName = (Twine(
"get") + UpperKey).str();
9250 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9251 if (ReturnType.
isNull()) {
9253 Builder.AddTextChunk(
"void");
9257 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9259 Builder.AddPlaceholderChunk(
"object-type");
9260 Builder.AddTextChunk(
" **");
9262 Builder.AddTextChunk(
"buffer");
9264 Builder.AddTypedTextChunk(
"range:");
9266 Builder.AddTextChunk(
"NSRange");
9268 Builder.AddTextChunk(
"inRange");
9269 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9277 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9278 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
9282 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9283 if (ReturnType.
isNull()) {
9285 Builder.AddTextChunk(
"void");
9289 Builder.AddTypedTextChunk(
"insertObject:");
9291 Builder.AddPlaceholderChunk(
"object-type");
9292 Builder.AddTextChunk(
" *");
9294 Builder.AddTextChunk(
"object");
9296 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9298 Builder.AddPlaceholderChunk(
"NSUInteger");
9300 Builder.AddTextChunk(
"index");
9301 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9307 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9308 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
9312 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9313 if (ReturnType.
isNull()) {
9315 Builder.AddTextChunk(
"void");
9319 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9321 Builder.AddTextChunk(
"NSArray *");
9323 Builder.AddTextChunk(
"array");
9325 Builder.AddTypedTextChunk(
"atIndexes:");
9327 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9329 Builder.AddTextChunk(
"indexes");
9330 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9336 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9337 std::string SelectorName =
9338 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
9340 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9341 if (ReturnType.
isNull()) {
9343 Builder.AddTextChunk(
"void");
9347 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9349 Builder.AddTextChunk(
"NSUInteger");
9351 Builder.AddTextChunk(
"index");
9352 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9358 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9359 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
9361 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9362 if (ReturnType.
isNull()) {
9364 Builder.AddTextChunk(
"void");
9368 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9370 Builder.AddTextChunk(
"NSIndexSet *");
9372 Builder.AddTextChunk(
"indexes");
9373 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9379 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9380 std::string SelectorName =
9381 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
9385 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9386 if (ReturnType.
isNull()) {
9388 Builder.AddTextChunk(
"void");
9392 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9394 Builder.AddPlaceholderChunk(
"NSUInteger");
9396 Builder.AddTextChunk(
"index");
9398 Builder.AddTypedTextChunk(
"withObject:");
9400 Builder.AddTextChunk(
"id");
9402 Builder.AddTextChunk(
"object");
9403 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9409 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9410 std::string SelectorName1 =
9411 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
9412 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
9416 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9417 if (ReturnType.
isNull()) {
9419 Builder.AddTextChunk(
"void");
9423 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName1 +
":"));
9425 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9427 Builder.AddTextChunk(
"indexes");
9429 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName2 +
":"));
9431 Builder.AddTextChunk(
"NSArray *");
9433 Builder.AddTextChunk(
"array");
9434 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9441 if (IsInstanceMethod &&
9447 ->
getName() ==
"NSEnumerator"))) {
9448 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
9452 if (ReturnType.
isNull()) {
9454 Builder.AddTextChunk(
"NSEnumerator *");
9458 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9459 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9465 if (IsInstanceMethod &&
9467 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
9469 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9470 if (ReturnType.
isNull()) {
9472 Builder.AddPlaceholderChunk(
"object-type");
9473 Builder.AddTextChunk(
" *");
9477 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9479 if (ReturnType.
isNull()) {
9480 Builder.AddPlaceholderChunk(
"object-type");
9481 Builder.AddTextChunk(
" *");
9484 ReturnType, Context, Policy, Builder.getAllocator()));
9487 Builder.AddTextChunk(
"object");
9488 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9495 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9496 std::string SelectorName =
9497 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
9499 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9500 if (ReturnType.
isNull()) {
9502 Builder.AddTextChunk(
"void");
9506 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9508 Builder.AddPlaceholderChunk(
"object-type");
9509 Builder.AddTextChunk(
" *");
9511 Builder.AddTextChunk(
"object");
9512 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9518 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9519 std::string SelectorName = (Twine(
"add") + UpperKey).str();
9521 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9522 if (ReturnType.
isNull()) {
9524 Builder.AddTextChunk(
"void");
9528 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9530 Builder.AddTextChunk(
"NSSet *");
9532 Builder.AddTextChunk(
"objects");
9533 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9539 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9540 std::string SelectorName =
9541 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
9543 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9544 if (ReturnType.
isNull()) {
9546 Builder.AddTextChunk(
"void");
9550 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9552 Builder.AddPlaceholderChunk(
"object-type");
9553 Builder.AddTextChunk(
" *");
9555 Builder.AddTextChunk(
"object");
9556 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9562 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9563 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
9565 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9566 if (ReturnType.
isNull()) {
9568 Builder.AddTextChunk(
"void");
9572 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9574 Builder.AddTextChunk(
"NSSet *");
9576 Builder.AddTextChunk(
"objects");
9577 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9583 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9584 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
9586 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9587 if (ReturnType.
isNull()) {
9589 Builder.AddTextChunk(
"void");
9593 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9595 Builder.AddTextChunk(
"NSSet *");
9597 Builder.AddTextChunk(
"objects");
9598 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9605 if (!IsInstanceMethod &&
9612 std::string SelectorName =
9613 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
9617 if (ReturnType.
isNull()) {
9619 Builder.AddTextChunk(
"NSSet<NSString *> *");
9623 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9630 if (!IsInstanceMethod &&
9633 std::string SelectorName =
9634 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
9638 if (ReturnType.
isNull()) {
9640 Builder.AddTextChunk(
"BOOL");
9644 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9652 Scope *S, std::optional<bool> IsInstanceMethod,
ParsedType ReturnTy) {
9657 Decl *IDecl =
nullptr;
9664 bool IsInImplementation =
false;
9665 if (
Decl *
D = IDecl) {
9667 SearchDecl = Impl->getClassInterface();
9668 IsInImplementation =
true;
9670 dyn_cast<ObjCCategoryImplDecl>(
D)) {
9671 SearchDecl = CatImpl->getCategoryDecl();
9672 IsInImplementation =
true;
9674 SearchDecl = dyn_cast<ObjCContainerDecl>(
D);
9677 if (!SearchDecl && S) {
9679 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
9695 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9696 CodeCompleter->getCodeCompletionTUInfo(),
9698 Results.EnterNewScope();
9700 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9701 MEnd = KnownMethods.end();
9705 Results.getCodeCompletionTUInfo());
9708 if (!IsInstanceMethod) {
9715 if (ReturnType.
isNull()) {
9726 Builder.AddTypedTextChunk(
9733 P != PEnd; (
void)++
P, ++I) {
9736 Builder.AddTypedTextChunk(
9740 Builder.AddTypedTextChunk(
9748 ParamType = (*P)->getType();
9750 ParamType = (*P)->getOriginalType();
9755 Context, Policy, Builder);
9758 Builder.AddTextChunk(
9759 Builder.getAllocator().CopyString(
Id->getName()));
9766 Builder.AddTextChunk(
"...");
9769 if (IsInImplementation && Results.includeCodePatterns()) {
9776 Builder.AddTextChunk(
"return");
9778 Builder.AddPlaceholderChunk(
"expression");
9781 Builder.AddPlaceholderChunk(
"statements");
9789 if (!M->second.getInt())
9791 Results.AddResult(std::move(R));
9798 Containers.push_back(SearchDecl);
9801 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9802 MEnd = KnownMethods.end();
9804 KnownSelectors.insert(M->first);
9809 IFace =
Category->getClassInterface();
9814 if (IsInstanceMethod) {
9815 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
9816 for (
auto *
P : Containers[I]->instance_properties())
9818 KnownSelectors, Results);
9822 Results.ExitScope();
9825 Results.getCompletionContext(), Results.data(),
9830 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
9835 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
9847 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9848 CodeCompleter->getCodeCompletionTUInfo(),
9852 Results.setPreferredType(
9855 Results.EnterNewScope();
9860 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
9861 : &M->second.second;
9862 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
9866 if (AtParameterName) {
9868 unsigned NumSelIdents = SelIdents.size();
9870 NumSelIdents <= MethList->getMethod()->param_size()) {
9872 MethList->getMethod()->parameters()[NumSelIdents - 1];
9875 Results.getCodeCompletionTUInfo());
9876 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
9878 Results.AddResult(Builder.TakeString());
9885 Result R(MethList->getMethod(),
9886 Results.getBasePriority(MethList->getMethod()),
nullptr);
9887 R.StartParameter = SelIdents.size();
9888 R.AllParametersAreInformative =
false;
9889 R.DeclaringEntity =
true;
9890 Results.MaybeAddResult(R, SemaRef.
CurContext);
9894 Results.ExitScope();
9896 if (!AtParameterName && !SelIdents.empty() &&
9897 SelIdents.front()->getName().starts_with(
"init")) {
9898 for (
const auto &M : SemaRef.
PP.
macros()) {
9899 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
9901 Results.EnterNewScope();
9903 Results.getCodeCompletionTUInfo());
9904 Builder.AddTypedTextChunk(
9905 Builder.getAllocator().CopyString(M.first->getName()));
9908 Results.ExitScope();
9913 Results.getCompletionContext(), Results.data(),
9918 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9919 CodeCompleter->getCodeCompletionTUInfo(),
9921 Results.EnterNewScope();
9925 Results.getCodeCompletionTUInfo());
9926 Builder.AddTypedTextChunk(
"if");
9928 Builder.AddPlaceholderChunk(
"condition");
9929 Results.AddResult(Builder.TakeString());
9932 Builder.AddTypedTextChunk(
"ifdef");
9934 Builder.AddPlaceholderChunk(
"macro");
9935 Results.AddResult(Builder.TakeString());
9938 Builder.AddTypedTextChunk(
"ifndef");
9940 Builder.AddPlaceholderChunk(
"macro");
9941 Results.AddResult(Builder.TakeString());
9943 if (InConditional) {
9945 Builder.AddTypedTextChunk(
"elif");
9947 Builder.AddPlaceholderChunk(
"condition");
9948 Results.AddResult(Builder.TakeString());
9951 Builder.AddTypedTextChunk(
"elifdef");
9953 Builder.AddPlaceholderChunk(
"macro");
9954 Results.AddResult(Builder.TakeString());
9957 Builder.AddTypedTextChunk(
"elifndef");
9959 Builder.AddPlaceholderChunk(
"macro");
9960 Results.AddResult(Builder.TakeString());
9963 Builder.AddTypedTextChunk(
"else");
9964 Results.AddResult(Builder.TakeString());
9967 Builder.AddTypedTextChunk(
"endif");
9968 Results.AddResult(Builder.TakeString());
9972 Builder.AddTypedTextChunk(
"include");
9974 Builder.AddTextChunk(
"\"");
9975 Builder.AddPlaceholderChunk(
"header");
9976 Builder.AddTextChunk(
"\"");
9977 Results.AddResult(Builder.TakeString());
9980 Builder.AddTypedTextChunk(
"include");
9982 Builder.AddTextChunk(
"<");
9983 Builder.AddPlaceholderChunk(
"header");
9984 Builder.AddTextChunk(
">");
9985 Results.AddResult(Builder.TakeString());
9988 Builder.AddTypedTextChunk(
"define");
9990 Builder.AddPlaceholderChunk(
"macro");
9991 Results.AddResult(Builder.TakeString());
9994 Builder.AddTypedTextChunk(
"define");
9996 Builder.AddPlaceholderChunk(
"macro");
9998 Builder.AddPlaceholderChunk(
"args");
10000 Results.AddResult(Builder.TakeString());
10003 Builder.AddTypedTextChunk(
"undef");
10005 Builder.AddPlaceholderChunk(
"macro");
10006 Results.AddResult(Builder.TakeString());
10009 Builder.AddTypedTextChunk(
"line");
10011 Builder.AddPlaceholderChunk(
"number");
10012 Results.AddResult(Builder.TakeString());
10015 Builder.AddTypedTextChunk(
"line");
10017 Builder.AddPlaceholderChunk(
"number");
10019 Builder.AddTextChunk(
"\"");
10020 Builder.AddPlaceholderChunk(
"filename");
10021 Builder.AddTextChunk(
"\"");
10022 Results.AddResult(Builder.TakeString());
10025 Builder.AddTypedTextChunk(
"error");
10027 Builder.AddPlaceholderChunk(
"message");
10028 Results.AddResult(Builder.TakeString());
10031 Builder.AddTypedTextChunk(
"pragma");
10033 Builder.AddPlaceholderChunk(
"arguments");
10034 Results.AddResult(Builder.TakeString());
10036 if (getLangOpts().
ObjC) {
10038 Builder.AddTypedTextChunk(
"import");
10040 Builder.AddTextChunk(
"\"");
10041 Builder.AddPlaceholderChunk(
"header");
10042 Builder.AddTextChunk(
"\"");
10043 Results.AddResult(Builder.TakeString());
10046 Builder.AddTypedTextChunk(
"import");
10048 Builder.AddTextChunk(
"<");
10049 Builder.AddPlaceholderChunk(
"header");
10050 Builder.AddTextChunk(
">");
10051 Results.AddResult(Builder.TakeString());
10055 Builder.AddTypedTextChunk(
"include_next");
10057 Builder.AddTextChunk(
"\"");
10058 Builder.AddPlaceholderChunk(
"header");
10059 Builder.AddTextChunk(
"\"");
10060 Results.AddResult(Builder.TakeString());
10063 Builder.AddTypedTextChunk(
"include_next");
10065 Builder.AddTextChunk(
"<");
10066 Builder.AddPlaceholderChunk(
"header");
10067 Builder.AddTextChunk(
">");
10068 Results.AddResult(Builder.TakeString());
10071 Builder.AddTypedTextChunk(
"warning");
10073 Builder.AddPlaceholderChunk(
"message");
10074 Results.AddResult(Builder.TakeString());
10081 Results.ExitScope();
10084 Results.getCompletionContext(), Results.data(),
10090 CodeCompleteOrdinaryName(S, S->getFnParent()
10096 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10097 CodeCompleter->getCodeCompletionTUInfo(),
10100 if (!IsDefinition && CodeCompleter->includeMacros()) {
10103 Results.getCodeCompletionTUInfo());
10104 Results.EnterNewScope();
10108 Builder.AddTypedTextChunk(
10109 Builder.getAllocator().CopyString(M->first->getName()));
10113 Results.ExitScope();
10114 }
else if (IsDefinition) {
10119 Results.getCompletionContext(), Results.data(),
10124 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10125 CodeCompleter->getCodeCompletionTUInfo(),
10128 if (CodeCompleter->includeMacros())
10132 Results.EnterNewScope();
10134 Results.getCodeCompletionTUInfo());
10135 Builder.AddTypedTextChunk(
"defined");
10138 Builder.AddPlaceholderChunk(
"macro");
10140 Results.AddResult(Builder.TakeString());
10141 Results.ExitScope();
10144 Results.getCompletionContext(), Results.data(),
10164 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
10167 llvm::sys::path::native(NativeRelDir);
10168 llvm::vfs::FileSystem &FS =
10171 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10172 CodeCompleter->getCodeCompletionTUInfo(),
10174 llvm::DenseSet<StringRef> SeenResults;
10177 auto AddCompletion = [&](StringRef
Filename,
bool IsDirectory) {
10180 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
10181 auto R = SeenResults.insert(TypedChunk);
10183 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
10184 *R.first = InternedTyped;
10186 CodeCompleter->getCodeCompletionTUInfo());
10187 Builder.AddTypedTextChunk(InternedTyped);
10195 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
10199 if (!NativeRelDir.empty()) {
10203 auto Begin = llvm::sys::path::begin(NativeRelDir);
10204 auto End = llvm::sys::path::end(NativeRelDir);
10206 llvm::sys::path::append(Dir, *
Begin +
".framework",
"Headers");
10207 llvm::sys::path::append(Dir, ++
Begin, End);
10209 llvm::sys::path::append(Dir, NativeRelDir);
10213 const StringRef &Dirname = llvm::sys::path::filename(Dir);
10214 const bool isQt = Dirname.starts_with(
"Qt") || Dirname ==
"ActiveQt";
10215 const bool ExtensionlessHeaders =
10216 IsSystem || isQt || Dir.ends_with(
".framework/Headers");
10217 std::error_code EC;
10218 unsigned Count = 0;
10219 for (
auto It = FS.dir_begin(Dir, EC);
10220 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
10221 if (++Count == 2500)
10223 StringRef
Filename = llvm::sys::path::filename(It->path());
10228 llvm::sys::fs::file_type
Type = It->type();
10229 if (
Type == llvm::sys::fs::file_type::symlink_file) {
10230 if (
auto FileStatus = FS.status(It->path()))
10231 Type = FileStatus->getType();
10234 case llvm::sys::fs::file_type::directory_file:
10238 NativeRelDir.empty() && !
Filename.consume_back(
".framework"))
10243 case llvm::sys::fs::file_type::regular_file: {
10245 const bool IsHeader =
Filename.ends_with_insensitive(
".h") ||
10246 Filename.ends_with_insensitive(
".hh") ||
10247 Filename.ends_with_insensitive(
".hpp") ||
10248 Filename.ends_with_insensitive(
".hxx") ||
10249 Filename.ends_with_insensitive(
".inc") ||
10250 (ExtensionlessHeaders && !
Filename.contains(
'.'));
10265 switch (IncludeDir.getLookupType()) {
10270 AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
10274 AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
10284 using llvm::make_range;
10288 AddFilesFromIncludeDir(CurFile->getDir().getName(),
false,
10290 for (
const auto &
D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
10291 AddFilesFromDirLookup(
D,
false);
10293 for (
const auto &
D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
10294 AddFilesFromDirLookup(
D,
false);
10295 for (
const auto &
D : make_range(S.system_dir_begin(), S.system_dir_end()))
10296 AddFilesFromDirLookup(
D,
true);
10299 Results.getCompletionContext(), Results.data(),
10310 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10311 CodeCompleter->getCodeCompletionTUInfo(),
10313 Results.EnterNewScope();
10314 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
10318 Twine(Platform) +
"ApplicationExtension")));
10320 Results.ExitScope();
10322 Results.getCompletionContext(), Results.data(),
10329 ResultBuilder Builder(SemaRef, Allocator, CCTUInfo,
10331 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
10332 CodeCompletionDeclConsumer Consumer(
10333 Builder, getASTContext().getTranslationUnitDecl());
10336 !CodeCompleter || CodeCompleter->loadExternal());
10339 if (!CodeCompleter || CodeCompleter->includeMacros())
10341 !CodeCompleter || CodeCompleter->loadExternal(),
true);
10344 Results.insert(Results.end(), Builder.data(),
10345 Builder.data() + Builder.size());
10350 :
SemaBase(S), CodeCompleter(CompletionConsumer) {}
This file provides AST data structures related to concepts.
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines an enumeration for C++ overloaded operators.
Defines the clang::Preprocessor interface.
static std::string getName(const CallEvent &Call)
static AccessResult IsAccessible(Sema &S, const EffectiveContext &EC, AccessTarget &Entity)
Determines whether the accessed entity is accessible.
static QualType getPreferredArgumentTypeForMessageSend(ResultBuilder &Results, unsigned NumSelIdents)
Given a set of code-completion results for the argument of a message send, determine the preferred ty...
static void printOverrideString(const CodeCompletionString &CCS, std::string &BeforeName, std::string &NameAndSignature)
static bool isConstructor(const Decl *ND)
static void findTypeLocationForBlockDecl(const TypeSourceInfo *TSInfo, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlock=false)
Tries to find the most appropriate type location for an Objective-C block placeholder.
static void AddQualifierToCompletionString(CodeCompletionBuilder &Result, NestedNameSpecifier *Qualifier, bool QualifierIsInformative, ASTContext &Context, const PrintingPolicy &Policy)
Add a qualifier to the given code-completion string, if the provided nested-name-specifier is non-NUL...
static bool isObjCReceiverType(ASTContext &C, QualType T)
static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, bool LoadExternal, bool IncludeUndefined, bool TargetTypeIsPointer=false)
static std::string formatTemplateParameterPlaceholder(const NamedDecl *Param, bool &Optional, const PrintingPolicy &Policy)
static std::string formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlockName=false, bool SuppressBlock=false, std::optional< ArrayRef< QualType > > ObjCSubsts=std::nullopt)
Returns a placeholder string that corresponds to an Objective-C block declaration.
static void AddTemplateParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const TemplateDecl *Template, CodeCompletionBuilder &Result, unsigned MaxParameters=0, unsigned Start=0, bool InDefaultArg=false)
Add template parameter chunks to the given code completion string.
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
static FunctionProtoTypeLoc GetPrototypeLoc(Expr *Fn)
static void AddFunctionParameterChunks(Preprocessor &PP, const PrintingPolicy &Policy, const FunctionDecl *Function, CodeCompletionBuilder &Result, unsigned Start=0, bool InOptional=false)
Add function parameter chunks to the given code completion string.
llvm::SmallPtrSet< const IdentifierInfo *, 16 > AddedPropertiesSet
The set of properties that have already been added, referenced by property name.
static bool argMatchesTemplateParams(const ParsedTemplateArgument &Arg, unsigned Index, const TemplateParameterList &Params)
static void setInBaseClass(ResultBuilder::Result &R)
static void AddObjCMethods(ObjCContainerDecl *Container, bool WantInstanceMethods, ObjCMethodKind WantKind, ArrayRef< const IdentifierInfo * > SelIdents, DeclContext *CurContext, VisitedSelectorSet &Selectors, bool AllowSameLength, ResultBuilder &Results, bool InOriginalClass=true, bool IsRootClass=false)
Add all of the Objective-C methods in the given Objective-C container to the set of results.
static bool shouldIgnoreDueToReservedName(const NamedDecl *ND, Sema &SemaRef)
static RecordDecl * getAsRecordDecl(QualType BaseType)
static CodeCompletionString * createTemplateSignatureString(const TemplateDecl *TD, CodeCompletionBuilder &Builder, unsigned CurrentArg, const PrintingPolicy &Policy)
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
static void AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
static const NamedDecl * extractFunctorCallOperator(const NamedDecl *ND)
static void AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
static QualType ProduceSignatureHelp(Sema &SemaRef, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, SourceLocation OpenParLoc, bool Braced)
static 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::@1291::AnnotatingParser::Context::@350 ContextType
C Language Family Type Representation.
pointer(const DeclIndexPair &Value)
const DeclIndexPair * operator->() const
pointer operator->() const
reference operator*() const
std::ptrdiff_t difference_type
friend bool operator!=(const iterator &X, const iterator &Y)
iterator(const NamedDecl *SingleDecl, unsigned Index)
std::input_iterator_tag iterator_category
iterator(const DeclIndexPair *Iterator)
friend bool operator==(const iterator &X, const iterator &Y)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
DeclarationNameTable DeclarationNames
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
SelectorTable & Selectors
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getElementType() const
Syntax
The style used to specify an attribute.
Type source information for an attributed type.
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Wrapper for source info for block pointers.
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Represents a static or instance method of a struct/union/class.
overridden_method_range overridden_methods() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Qualifiers getMethodQualifiers() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
CXXRecordDecl * getDefinition() const
base_class_range vbases()
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CaseStmt - Represent a case statement.
Represents a character-granular source range.
static CharSourceRange getTokenRange(SourceRange R)
Declaration of a class template.
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments, bool Braced) const
Create a new code-completion string that describes the function signature of this overload candidate.
const FunctionType * getFunctionType() const
Retrieve the function type of the entity, regardless of how the function is stored.
const TemplateDecl * getTemplate() const
CandidateKind getKind() const
Determine the kind of overload candidate.
const RecordDecl * getAggregate() const
Retrieve the aggregate type being initialized.
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
const FunctionProtoTypeLoc getFunctionProtoTypeLoc() const
Retrieve the function ProtoTypeLoc candidate.
@ CK_Aggregate
The candidate is aggregate initialization of a record type.
@ CK_Template
The candidate is a template, template arguments are being completed.
unsigned getNumParams() const
Get the number of parameters in this signature.
Abstract interface for a consumer of code-completion information.
bool includeGlobals() const
Whether to include global (top-level) declaration results.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results.
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced)
An allocator used specifically for the purpose of code completion.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
A builder class used to construct new code-completion strings.
CodeCompletionString * TakeString()
Take the resulting completion string.
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
void AddTextChunk(const char *Text)
Add a new text chunk.
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
The context in which code completion occurred, so that the code-completion consumer can process the r...
Kind getKind() const
Retrieve the kind of code-completion context.
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
@ CCC_TypeQualifiers
Code completion within a type-qualifier list.
@ CCC_ObjCMessageReceiver
Code completion occurred where an Objective-C message receiver is expected.
@ CCC_PreprocessorExpression
Code completion occurred within a preprocessor expression.
@ CCC_ObjCCategoryName
Code completion where an Objective-C category name is expected.
@ CCC_ObjCIvarList
Code completion occurred within the instance variable list of an Objective-C interface,...
@ CCC_Statement
Code completion occurred where a statement (or declaration) is expected in a function,...
@ CCC_Type
Code completion occurred where a type name is expected.
@ CCC_ArrowMemberAccess
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
@ CCC_ClassStructUnion
Code completion occurred within a class, struct, or union.
@ CCC_ObjCInterface
Code completion occurred within an Objective-C interface, protocol, or category interface.
@ CCC_ObjCPropertyAccess
Code completion occurred on the right-hand side of an Objective-C property access expression.
@ CCC_Expression
Code completion occurred where an expression is expected.
@ CCC_SelectorName
Code completion for a selector, as in an @selector expression.
@ CCC_TopLevelOrExpression
Code completion at a top level, i.e.
@ CCC_EnumTag
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
@ CCC_UnionTag
Code completion occurred after the "union" keyword, to indicate a union name.
@ CCC_ParenthesizedExpression
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
@ CCC_TopLevel
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope.
@ CCC_ClassOrStructTag
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name.
@ CCC_ObjCClassMessage
Code completion where an Objective-C class message is expected.
@ CCC_ObjCImplementation
Code completion occurred within an Objective-C implementation or category implementation.
@ CCC_IncludedFile
Code completion inside the filename part of a #include directive.
@ CCC_ObjCInstanceMessage
Code completion where an Objective-C instance message is expected.
@ CCC_SymbolOrNewName
Code completion occurred where both a new name and an existing symbol is permissible.
@ CCC_Recovery
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
@ CCC_ObjCProtocolName
Code completion occurred where a protocol name is expected.
@ CCC_NewName
Code completion occurred where a new name is expected.
@ CCC_MacroNameUse
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
@ CCC_Symbol
Code completion occurred where an existing name(such as type, function or variable) is expected.
@ CCC_Attribute
Code completion of an attribute name.
@ CCC_Other
An unspecified code-completion context.
@ CCC_DotMemberAccess
Code completion occurred on the right-hand side of a member access expression using the dot operator.
@ CCC_MacroName
Code completion occurred where an macro is being defined.
@ CCC_Namespace
Code completion occurred where a namespace or namespace alias is expected.
@ CCC_PreprocessorDirective
Code completion occurred where a preprocessor directive is expected.
@ CCC_NaturalLanguage
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
@ CCC_ObjCInterfaceName
Code completion where the name of an Objective-C class is expected.
@ CCC_ObjCClassForwardDecl
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
void setPreferredType(QualType T)
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
void setIsUsingDeclaration(bool V)
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
Captures a result of code completion.
bool DeclaringEntity
Whether we're completing a declaration of the given entity, rather than a use of that entity.
ResultKind Kind
The kind of result stored here.
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling.
CXAvailabilityKind Availability
The availability of this result.
NestedNameSpecifier * Qualifier
If the result should have a nested-name-specifier, this is it.
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program.
bool QualifierIsInformative
Whether this result was found via lookup into a base class.
const NamedDecl * Declaration
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to.
CodeCompletionString * createCodeCompletionStringForDecl(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
CodeCompletionString * CreateCodeCompletionStringForMacro(Preprocessor &PP, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Creates a new code-completion string for the macro result.
unsigned StartParameter
Specifies which parameter (of a function, Objective-C method, macro, etc.) we should start with when ...
bool InBaseClass
Whether this is a class member from base class.
unsigned Priority
The priority of this particular code-completion result.
bool StartsNestedNameSpecifier
Whether this declaration is the beginning of a nested-name-specifier and, therefore,...
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert.
bool FunctionCanBeCall
When completing a function, whether it can be a call.
bool AllParametersAreInformative
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative".
CodeCompletionString * createCodeCompletionStringForOverride(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
const IdentifierInfo * Macro
When Kind == RK_Macro, the identifier that refers to a macro.
@ RK_Pattern
Refers to a precomputed pattern.
@ RK_Declaration
Refers to a declaration.
@ RK_Macro
Refers to a macro.
@ RK_Keyword
Refers to a keyword or symbol.
A "string" used to describe how code completion can be performed for an entity.
@ CK_Optional
A code completion string that is entirely optional.
@ CK_CurrentParameter
A piece of text that describes the parameter that corresponds to the code-completion location within ...
@ CK_Comma
A comma separator (',').
@ CK_Placeholder
A string that acts as a placeholder for, e.g., a function call argument.
@ CK_LeftParen
A left parenthesis ('(').
@ CK_HorizontalSpace
Horizontal whitespace (' ').
@ CK_RightAngle
A right angle bracket ('>').
@ CK_LeftBracket
A left bracket ('[').
@ CK_RightParen
A right parenthesis (')').
@ CK_RightBrace
A right brace ('}').
@ CK_VerticalSpace
Vertical whitespace ('\n' or '\r\n', depending on the platform).
@ CK_SemiColon
A semicolon (';').
@ CK_TypedText
The piece of text that the user is expected to type to match the code-completion string,...
@ CK_RightBracket
A right bracket (']').
@ CK_LeftBrace
A left brace ('{').
@ CK_LeftAngle
A left angle bracket ('<').
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
const TypeClass * getTypePtr() const
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool 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.
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.
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...
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 Alloc(InterpState &S, CodePtr OpPC, const Descriptor *Desc)
bool Add(InterpState &S, CodePtr OpPC)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
@ 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.
QualType getDeclUsageType(ASTContext &C, const NamedDecl *ND)
Determine the type that this declaration will have if it is used as a type or in an expression.
bool isReservedInAllContexts(ReservedIdentifierStatus Status)
Determine whether an identifier is reserved in all contexts.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
const RawComment * getParameterComment(const ASTContext &Ctx, const CodeCompleteConsumer::OverloadCandidate &Result, unsigned ArgIndex)
Get the documentation comment used to produce CodeCompletionString::BriefComment for OverloadCandidat...
@ LCK_This
Capturing the *this object by reference.
@ IK_ConstructorName
A constructor name.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ Property
The type of a property.
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion.
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern.
@ CCF_ExactTypeMatch
Divide by this factor when a code-completion result's type exactly matches the type we expect.
@ CCF_SimilarTypeMatch
Divide by this factor when a code-completion result's type is similar to the type we expect (e....
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
const RawComment * getCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Declaration.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
@ 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.
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...
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)
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.