49#include "llvm/ADT/ArrayRef.h"
50#include "llvm/ADT/DenseSet.h"
51#include "llvm/ADT/SmallBitVector.h"
52#include "llvm/ADT/SmallPtrSet.h"
53#include "llvm/ADT/SmallString.h"
54#include "llvm/ADT/StringSet.h"
55#include "llvm/ADT/StringSwitch.h"
56#include "llvm/ADT/Twine.h"
57#include "llvm/ADT/iterator_range.h"
58#include "llvm/Support/Casting.h"
59#include "llvm/Support/FileSystem.h"
60#include "llvm/Support/Path.h"
61#include "llvm/Support/VirtualFileSystem.h"
62#include "llvm/Support/raw_ostream.h"
81 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
83 typedef CodeCompletionResult Result;
87 std::vector<Result> Results;
92 llvm::SmallPtrSet<const Decl *, 16> AllDeclsFound;
94 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
99 class ShadowMapEntry {
100 typedef SmallVector<DeclIndexPair, 4> DeclIndexPairVector;
104 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector *> DeclOrVector;
108 unsigned SingleDeclIndex = 0;
111 ShadowMapEntry() =
default;
112 ShadowMapEntry(
const ShadowMapEntry &) =
delete;
113 ShadowMapEntry(ShadowMapEntry &&Move) { *
this = std::move(Move); }
114 ShadowMapEntry &operator=(
const ShadowMapEntry &) =
delete;
115 ShadowMapEntry &operator=(ShadowMapEntry &&Move) {
116 SingleDeclIndex =
Move.SingleDeclIndex;
117 DeclOrVector =
Move.DeclOrVector;
118 Move.DeclOrVector =
nullptr;
122 void Add(
const NamedDecl *ND,
unsigned Index) {
123 if (DeclOrVector.isNull()) {
126 SingleDeclIndex = Index;
130 if (
const NamedDecl *PrevND = dyn_cast<const NamedDecl *>(DeclOrVector)) {
133 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
134 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
140 ->push_back(DeclIndexPair(ND, Index));
144 if (DeclIndexPairVector *Vec =
145 dyn_cast_if_present<DeclIndexPairVector *>(DeclOrVector)) {
147 DeclOrVector = ((NamedDecl *)
nullptr);
160 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
167 CodeCompletionAllocator &Allocator;
169 CodeCompletionTUInfo &CCTUInfo;
177 bool AllowNestedNameSpecifiers;
188 std::list<ShadowMap> ShadowMaps;
192 llvm::DenseMap<std::pair<DeclContext *,
uintptr_t>, ShadowMapEntry>
197 Qualifiers ObjectTypeQualifiers;
202 bool HasObjectTypeQualifiers;
205 bool IsExplicitObjectMemberFunction;
208 Selector PreferredSelector;
211 CodeCompletionContext CompletionContext;
215 ObjCImplementationDecl *ObjCImplementation;
217 void AdjustResultPriorityForDecl(Result &R);
219 void MaybeAddConstructorResults(Result R);
222 explicit ResultBuilder(Sema &SemaRef, CodeCompletionAllocator &Allocator,
223 CodeCompletionTUInfo &CCTUInfo,
224 const CodeCompletionContext &CompletionContext,
225 LookupFilter Filter =
nullptr)
226 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
227 Filter(Filter), AllowNestedNameSpecifiers(
false),
228 HasObjectTypeQualifiers(
false), IsExplicitObjectMemberFunction(
false),
229 CompletionContext(CompletionContext), ObjCImplementation(
nullptr) {
232 switch (CompletionContext.getKind()) {
233 case CodeCompletionContext::CCC_Expression:
234 case CodeCompletionContext::CCC_ObjCMessageReceiver:
235 case CodeCompletionContext::CCC_ParenthesizedExpression:
236 case CodeCompletionContext::CCC_Statement:
237 case CodeCompletionContext::CCC_TopLevelOrExpression:
238 case CodeCompletionContext::CCC_Recovery:
239 if (ObjCMethodDecl *Method = SemaRef.getCurMethodDecl())
240 if (Method->isInstanceMethod())
241 if (ObjCInterfaceDecl *Interface = Method->getClassInterface())
242 ObjCImplementation = Interface->getImplementation();
251 unsigned getBasePriority(
const NamedDecl *D);
255 bool includeCodePatterns()
const {
256 return SemaRef.CodeCompletion().CodeCompleter &&
257 SemaRef.CodeCompletion().CodeCompleter->includeCodePatterns();
261 void setFilter(LookupFilter Filter) { this->Filter = Filter; }
263 Result *data() {
return Results.empty() ?
nullptr : &Results.front(); }
264 unsigned size()
const {
return Results.size(); }
265 bool empty()
const {
return Results.empty(); }
268 void setPreferredType(QualType
T) {
269 PreferredType = SemaRef.Context.getCanonicalType(
T);
279 void setObjectTypeQualifiers(Qualifiers Quals,
ExprValueKind Kind) {
280 ObjectTypeQualifiers = Quals;
282 HasObjectTypeQualifiers =
true;
285 void setExplicitObjectMemberFn(
bool IsExplicitObjectFn) {
286 IsExplicitObjectMemberFunction = IsExplicitObjectFn;
294 void setPreferredSelector(Selector Sel) { PreferredSelector = Sel; }
298 const CodeCompletionContext &getCompletionContext()
const {
299 return CompletionContext;
303 void allowNestedNameSpecifiers(
bool Allow =
true) {
304 AllowNestedNameSpecifiers =
Allow;
309 Sema &getSema()
const {
return SemaRef; }
312 CodeCompletionAllocator &getAllocator()
const {
return Allocator; }
314 CodeCompletionTUInfo &getCodeCompletionTUInfo()
const {
return CCTUInfo; }
323 bool isInterestingDecl(
const NamedDecl *ND,
324 bool &AsNestedNameSpecifier)
const;
332 bool canFunctionBeCalled(
const NamedDecl *ND, QualType BaseExprType)
const;
340 bool canCxxMethodBeCalled(
const CXXMethodDecl *
Method,
341 QualType BaseExprType)
const;
349 bool CheckHiddenResult(Result &R, DeclContext *CurContext,
350 const NamedDecl *Hiding);
359 void MaybeAddResult(Result R, DeclContext *CurContext =
nullptr);
375 void AddResult(Result R, DeclContext *CurContext, NamedDecl *Hiding,
376 bool InBaseClass, QualType BaseExprType,
377 bool IsInDeclarationContext,
bool IsAddressOfOperand);
380 void AddResult(Result R);
383 void EnterNewScope();
392 void addVisitedContext(DeclContext *Ctx) {
393 CompletionContext.addVisitedContext(Ctx);
402 bool IsOrdinaryName(
const NamedDecl *ND)
const;
403 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
404 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
405 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
406 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
407 bool IsEnum(
const NamedDecl *ND)
const;
408 bool IsClassOrStruct(
const NamedDecl *ND)
const;
409 bool IsUnion(
const NamedDecl *ND)
const;
410 bool IsNamespace(
const NamedDecl *ND)
const;
411 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
412 bool IsType(
const NamedDecl *ND)
const;
413 bool IsMember(
const NamedDecl *ND)
const;
414 bool IsOffsetofField(
const NamedDecl *ND)
const;
415 bool IsObjCIvar(
const NamedDecl *ND)
const;
416 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
417 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
418 bool IsObjCCollection(
const NamedDecl *ND)
const;
419 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
432 for (
auto *Redecl : Function->getFirstDecl()->redecls()) {
436 if (Redecl->getNumParams() < ParaCount)
438 for (
unsigned P = Start, N = Redecl->getNumParams(); P != N; ++P)
439 if (Redecl->getParamDecl(P)->getIdentifier())
451 ComputeType =
nullptr;
452 Type = BSI->ReturnType;
456 ComputeType =
nullptr;
460 ComputeType =
nullptr;
461 Type =
Method->getReturnType();
469 auto *VD = llvm::dyn_cast_or_null<ValueDecl>(D);
470 ComputeType =
nullptr;
471 Type = VD ? VD->getType() :
QualType();
487 ComputeType =
nullptr;
497 this->ComputeType = ComputeType;
507 if (ExpectedLoc == LParLoc)
518 if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
521 if (Op == tok::minus)
534 case tok::minusequal:
536 case tok::percentequal:
538 case tok::slashequal:
544 case tok::equalequal:
545 case tok::exclaimequal:
549 case tok::greaterequal:
553 case tok::greatergreater:
554 case tok::greatergreaterequal:
556 case tok::lesslessequal:
569 case tok::caretequal:
577 case tok::periodstar:
595 if (!ContextType.isNull() && ContextType->isPointerType())
596 return ContextType->getPointeeType();
599 if (ContextType.isNull())
605 case tok::minusminus:
607 if (ContextType.isNull())
615 assert(
false &&
"unhandled unary op");
624 ComputeType =
nullptr;
631 if (!Enabled || !
Base)
634 if (ExpectedLoc !=
Base->getBeginLoc())
645 ComputeType =
nullptr;
654 ComputeType =
nullptr;
663 ComputeType =
nullptr;
671 ComputeType =
nullptr;
677 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
678 unsigned SingleDeclIndex;
690 pointer(
const DeclIndexPair &Value) : Value(Value) {}
698 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) {}
701 : DeclOrIterator(Iterator), SingleDeclIndex(0) {}
723 if (
const NamedDecl *ND = dyn_cast<const NamedDecl *>(DeclOrIterator))
732 return X.DeclOrIterator.getOpaqueValue() ==
733 Y.DeclOrIterator.getOpaqueValue() &&
734 X.SingleDeclIndex == Y.SingleDeclIndex;
743ResultBuilder::ShadowMapEntry::begin()
const {
744 if (DeclOrVector.isNull())
747 if (
const NamedDecl *ND = dyn_cast<const NamedDecl *>(DeclOrVector))
748 return iterator(ND, SingleDeclIndex);
754ResultBuilder::ShadowMapEntry::end()
const {
779 for (
const DeclContext *CommonAncestor = TargetContext;
780 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
781 CommonAncestor = CommonAncestor->getLookupParent()) {
782 if (CommonAncestor->isTransparentContext() ||
783 CommonAncestor->isFunctionOrMethod())
786 TargetParents.push_back(CommonAncestor);
790 while (!TargetParents.empty()) {
791 const DeclContext *Parent = TargetParents.pop_back_val();
793 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
794 if (!Namespace->getIdentifier())
798 }
else if (
const auto *TD = dyn_cast<TagDecl>(Parent)) {
831bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
832 bool &AsNestedNameSpecifier)
const {
833 AsNestedNameSpecifier =
false;
859 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
861 Filter != &ResultBuilder::IsNamespaceOrAlias && Filter !=
nullptr))
862 AsNestedNameSpecifier =
true;
865 if (Filter && !(this->*Filter)(Named)) {
867 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
868 IsNestedNameSpecifier(ND) &&
869 (Filter != &ResultBuilder::IsMember ||
872 AsNestedNameSpecifier =
true;
891 R.Declaration->getDeclContext()->getRedeclContext();
902 R.QualifierIsInformative =
false;
906 R.Declaration->getDeclContext());
913 switch (
T->getTypeClass()) {
916 case BuiltinType::Void:
919 case BuiltinType::NullPtr:
922 case BuiltinType::Overload:
923 case BuiltinType::Dependent:
926 case BuiltinType::ObjCId:
927 case BuiltinType::ObjCClass:
928 case BuiltinType::ObjCSel:
941 case Type::BlockPointer:
944 case Type::LValueReference:
945 case Type::RValueReference:
948 case Type::ConstantArray:
949 case Type::IncompleteArray:
950 case Type::VariableArray:
951 case Type::DependentSizedArray:
954 case Type::DependentSizedExtVector:
956 case Type::ExtVector:
959 case Type::FunctionProto:
960 case Type::FunctionNoProto:
969 case Type::ObjCObject:
970 case Type::ObjCInterface:
971 case Type::ObjCObjectPointer:
985 if (
const auto *
Type = dyn_cast<TypeDecl>(ND))
987 if (
const auto *Iface = dyn_cast<ObjCInterfaceDecl>(ND))
988 return C.getObjCInterfaceType(Iface);
993 else if (
const auto *
Method = dyn_cast<ObjCMethodDecl>(ND))
994 T =
Method->getSendResultType();
995 else if (
const auto *
Enumerator = dyn_cast<EnumConstantDecl>(ND))
999 else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND))
1001 else if (
const auto *
Value = dyn_cast<ValueDecl>(ND))
1012 T = Ref->getPointeeType();
1017 if (
Pointer->getPointeeType()->isFunctionType()) {
1026 T =
Block->getPointeeType();
1041unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
1049 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
1050 if (ImplicitParam->getIdentifier() &&
1051 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
1080 CompletionContext.
getKind() ==
1082 CompletionContext.
getKind() ==
1089void ResultBuilder::AdjustResultPriorityForDecl(
Result &R) {
1092 if (!PreferredSelector.
isNull())
1093 if (
const auto *
Method = dyn_cast<ObjCMethodDecl>(
R.Declaration))
1094 if (PreferredSelector ==
Method->getSelector())
1099 if (!PreferredType.
isNull()) {
1109 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
1119 Context.DeclarationNames.getCXXConstructorName(RecordTy);
1120 return Record->lookup(ConstructorName);
1123void ResultBuilder::MaybeAddConstructorResults(
Result R) {
1124 if (!SemaRef.
getLangOpts().CPlusPlus || !
R.Declaration ||
1131 Record = ClassTemplate->getTemplatedDecl();
1132 else if ((
Record = dyn_cast<CXXRecordDecl>(D))) {
1146 R.Declaration = Ctor;
1148 Results.push_back(R);
1153 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
1154 ND = Tmpl->getTemplatedDecl();
1159 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
1161 if (
R.Kind != Result::RK_Declaration) {
1163 Results.push_back(R);
1168 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(
R.Declaration)) {
1170 getBasePriority(
Using->getTargetDecl()),
1174 std::move(
R.FixIts));
1176 MaybeAddResult(
Result, CurContext);
1180 const Decl *CanonDecl =
R.Declaration->getCanonicalDecl();
1183 bool AsNestedNameSpecifier =
false;
1184 if (!isInterestingDecl(
R.Declaration, AsNestedNameSpecifier))
1191 ShadowMap &SMap = ShadowMaps.back();
1192 ShadowMapEntry::iterator I, IEnd;
1193 ShadowMap::iterator NamePos = SMap.find(
R.Declaration->getDeclName());
1194 if (NamePos != SMap.end()) {
1195 I = NamePos->second.begin();
1196 IEnd = NamePos->second.end();
1199 for (; I != IEnd; ++I) {
1201 unsigned Index = I->second;
1204 Results[Index].Declaration =
R.Declaration;
1214 std::list<ShadowMap>::iterator SM, SMEnd = ShadowMaps.end();
1216 for (SM = ShadowMaps.begin(); SM != SMEnd; ++SM) {
1217 ShadowMapEntry::iterator I, IEnd;
1218 ShadowMap::iterator NamePos = SM->find(
R.Declaration->getDeclName());
1219 if (NamePos != SM->end()) {
1220 I = NamePos->second.begin();
1221 IEnd = NamePos->second.end();
1223 for (; I != IEnd; ++I) {
1225 if (I->first->hasTagIdentifierNamespace() &&
1233 I->first->getIdentifierNamespace() != IDNS)
1237 if (CheckHiddenResult(R, CurContext, I->first))
1245 if (!AllDeclsFound.insert(CanonDecl).second)
1250 if (AsNestedNameSpecifier) {
1251 R.StartsNestedNameSpecifier =
true;
1254 AdjustResultPriorityForDecl(R);
1257 if (
R.QualifierIsInformative && !
R.Qualifier &&
1258 !
R.StartsNestedNameSpecifier) {
1259 const DeclContext *Ctx =
R.Declaration->getDeclContext();
1260 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1263 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1267 std::nullopt, Tag,
false)
1270 R.QualifierIsInformative =
false;
1275 SMap[
R.Declaration->getDeclName()].Add(
R.Declaration, Results.size());
1276 Results.push_back(R);
1278 if (!AsNestedNameSpecifier)
1279 MaybeAddConstructorResults(R);
1284 R.InBaseClass =
true;
1305 for (
unsigned I = 0, E = Candidate.
getNumParams(); I != E; ++I)
1306 if (Candidate.
parameters()[I]->getType().getCanonicalType() !=
1307 Incumbent.
parameters()[I]->getType().getCanonicalType())
1316 if (CandidateRef != IncumbentRef) {
1332 if (CandidateSuperset == IncumbentSuperset)
1344 const auto *CurrentClassScope = [&]() ->
const CXXRecordDecl * {
1346 const auto *CtxMethod = llvm::dyn_cast<CXXMethodDecl>(Ctx);
1347 if (CtxMethod && !CtxMethod->getParent()->isLambda()) {
1348 return CtxMethod->getParent();
1355 bool FunctionCanBeCall =
1356 CurrentClassScope &&
1357 (CurrentClassScope ==
Method->getParent() ||
1358 CurrentClassScope->isDerivedFrom(
Method->getParent()));
1361 if (FunctionCanBeCall)
1366 BaseExprType.
isNull() ?
nullptr
1368 auto *MaybeBase =
Method->getParent();
1370 MaybeDerived == MaybeBase || MaybeDerived->isDerivedFrom(MaybeBase);
1373 return FunctionCanBeCall;
1376bool ResultBuilder::canFunctionBeCalled(
const NamedDecl *ND,
1387 if (
const auto *FuncTmpl = dyn_cast<FunctionTemplateDecl>(ND)) {
1388 ND = FuncTmpl->getTemplatedDecl();
1390 const auto *
Method = dyn_cast<CXXMethodDecl>(ND);
1392 return canCxxMethodBeCalled(
Method, BaseExprType);
1399 NamedDecl *Hiding,
bool InBaseClass =
false,
1401 bool IsInDeclarationContext =
false,
1402 bool IsAddressOfOperand =
false) {
1403 if (
R.Kind != Result::RK_Declaration) {
1405 Results.push_back(R);
1410 if (
const auto *Using = dyn_cast<UsingShadowDecl>(
R.Declaration)) {
1412 getBasePriority(
Using->getTargetDecl()),
1416 std::move(
R.FixIts));
1418 AddResult(
Result, CurContext, Hiding,
false,
1423 bool AsNestedNameSpecifier =
false;
1424 if (!isInterestingDecl(
R.Declaration, AsNestedNameSpecifier))
1431 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
1435 if (!AllDeclsFound.insert(
R.Declaration->getCanonicalDecl()).second)
1440 if (AsNestedNameSpecifier) {
1441 R.StartsNestedNameSpecifier =
true;
1443 }
else if (Filter == &ResultBuilder::IsMember && !
R.Qualifier &&
1446 R.Declaration->getDeclContext()->getRedeclContext()))
1447 R.QualifierIsInformative =
true;
1450 if (
R.QualifierIsInformative && !
R.Qualifier &&
1451 !
R.StartsNestedNameSpecifier) {
1452 const DeclContext *Ctx =
R.Declaration->getDeclContext();
1453 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1456 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1460 std::nullopt, Tag,
false)
1463 R.QualifierIsInformative =
false;
1470 AdjustResultPriorityForDecl(R);
1473 const auto GetQualifiers = [&](
const CXXMethodDecl *MethodDecl) {
1474 if (MethodDecl->isExplicitObjectMemberFunction())
1475 return MethodDecl->getFunctionObjectParameterType().getQualifiers();
1477 return MethodDecl->getMethodQualifiers();
1480 if (IsExplicitObjectMemberFunction &&
1489 if (HasObjectTypeQualifiers)
1490 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(
R.Declaration))
1491 if (
Method->isInstance()) {
1493 if (ObjectTypeQualifiers == MethodQuals)
1495 else if (ObjectTypeQualifiers - MethodQuals) {
1501 switch (
Method->getRefQualifier()) {
1518 CurContext,
Method->getDeclName().getAsOpaqueInteger())];
1520 Result &Incumbent = Results[Entry.second];
1523 ObjectTypeQualifiers, ObjectKind,
1529 Incumbent = std::move(R);
1540 R.DeclaringEntity = IsInDeclarationContext;
1541 R.FunctionCanBeCall =
1542 canFunctionBeCalled(
R.getDeclaration(), BaseExprType) &&
1546 !IsAddressOfOperand;
1549 Results.push_back(R);
1551 if (!AsNestedNameSpecifier)
1552 MaybeAddConstructorResults(R);
1555void ResultBuilder::AddResult(
Result R) {
1556 assert(
R.Kind != Result::RK_Declaration &&
1557 "Declaration results need more context");
1558 Results.push_back(R);
1562void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1565void ResultBuilder::ExitScope() {
1566 ShadowMaps.pop_back();
1571bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1589bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1596 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1597 if (!
ID->getDefinition())
1612bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1613 if (!IsOrdinaryNonTypeName(ND))
1617 if (VD->getType()->isIntegralOrEnumerationType())
1625bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1638bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1640 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1641 ND = ClassTemplate->getTemplatedDecl();
1647bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1652bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1654 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1655 ND = ClassTemplate->getTemplatedDecl();
1658 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1667bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1669 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1670 ND = ClassTemplate->getTemplatedDecl();
1672 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1679bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1685bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1690bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1698bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1706bool ResultBuilder::IsOffsetofField(
const NamedDecl *ND)
const {
1708 if (
const auto *FD = dyn_cast<FieldDecl>(ND))
1709 return !FD->isBitField();
1710 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(ND))
1711 return !IFD->getAnonField()->isBitField();
1716 T =
C.getCanonicalType(
T);
1717 switch (
T->getTypeClass()) {
1718 case Type::ObjCObject:
1719 case Type::ObjCInterface:
1720 case Type::ObjCObjectPointer:
1725 case BuiltinType::ObjCId:
1726 case BuiltinType::ObjCClass:
1727 case BuiltinType::ObjCSel:
1739 if (!
C.getLangOpts().CPlusPlus)
1745 return T->isDependentType() ||
T->isRecordType();
1748bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1758bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1760 if (IsObjCMessageReceiver(ND))
1763 const auto *Var = dyn_cast<VarDecl>(ND);
1767 return Var->hasLocalStorage() && !Var->hasAttr<BlocksAttr>();
1770bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1771 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1772 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1781 return T->isObjCObjectType() ||
T->isObjCObjectPointerType() ||
1782 T->isObjCIdType() ||
1786bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1792bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1801 ResultBuilder &Results;
1802 DeclContext *InitialLookupCtx;
1805 CXXRecordDecl *NamingClass;
1807 std::vector<FixItHint> FixIts;
1808 bool IsInDeclarationContext;
1810 bool IsAddressOfOperand;
1813 CodeCompletionDeclConsumer(
1814 ResultBuilder &Results, DeclContext *InitialLookupCtx,
1815 QualType BaseType = QualType(),
1816 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1817 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1818 FixIts(std::move(FixIts)), IsInDeclarationContext(
false),
1819 IsAddressOfOperand(
false) {
1820 NamingClass = llvm::dyn_cast<CXXRecordDecl>(InitialLookupCtx);
1823 auto ThisType = Results.getSema().getCurrentThisType();
1824 if (!ThisType.isNull()) {
1825 assert(ThisType->isPointerType());
1831 this->BaseType = BaseType;
1834 void setIsInDeclarationContext(
bool IsInDeclarationContext) {
1835 this->IsInDeclarationContext = IsInDeclarationContext;
1838 void setIsAddressOfOperand(
bool IsAddressOfOperand) {
1839 this->IsAddressOfOperand = IsAddressOfOperand;
1842 void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
1843 bool InBaseClass)
override {
1844 ResultBuilder::Result
Result(ND, Results.getBasePriority(ND),
1848 Results.AddResult(
Result, InitialLookupCtx, Hiding, InBaseClass, BaseType,
1849 IsInDeclarationContext, IsAddressOfOperand);
1852 void EnteredContext(DeclContext *Ctx)
override {
1853 Results.addVisitedContext(Ctx);
1862 auto *NamingClass = this->NamingClass;
1863 QualType BaseType = this->BaseType;
1864 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1873 BaseType = QualType();
1879 NamingClass =
nullptr;
1880 BaseType = QualType();
1882 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1889 ResultBuilder &Results) {
1916 Results.getCodeCompletionTUInfo());
1917 if (LangOpts.CPlusPlus) {
1925 Builder.AddTypedTextChunk(
"typename");
1927 Builder.AddPlaceholderChunk(
"name");
1928 Results.AddResult(
Result(Builder.TakeString()));
1930 if (LangOpts.CPlusPlus11) {
1935 Builder.AddTypedTextChunk(
"decltype");
1937 Builder.AddPlaceholderChunk(
"expression");
1939 Results.AddResult(
Result(Builder.TakeString()));
1942 if (LangOpts.Char8 || LangOpts.CPlusPlus20)
1948 if (LangOpts.GNUKeywords) {
1954 Builder.AddTypedTextChunk(
"typeof");
1956 Builder.AddPlaceholderChunk(
"expression");
1957 Results.AddResult(
Result(Builder.TakeString()));
1959 Builder.AddTypedTextChunk(
"typeof");
1961 Builder.AddPlaceholderChunk(
"type");
1963 Results.AddResult(
Result(Builder.TakeString()));
1974 const LangOptions &LangOpts, ResultBuilder &Results) {
1979 Results.AddResult(
Result(
"extern"));
1980 Results.AddResult(
Result(
"static"));
1982 if (LangOpts.CPlusPlus11) {
1987 Builder.AddTypedTextChunk(
"alignas");
1989 Builder.AddPlaceholderChunk(
"expression");
1991 Results.AddResult(
Result(Builder.TakeString()));
1993 Results.AddResult(
Result(
"constexpr"));
1994 Results.AddResult(
Result(
"thread_local"));
1997 if (LangOpts.CPlusPlus20)
1998 Results.AddResult(
Result(
"constinit"));
2003 const LangOptions &LangOpts, ResultBuilder &Results) {
2008 if (LangOpts.CPlusPlus) {
2009 Results.AddResult(
Result(
"explicit"));
2010 Results.AddResult(
Result(
"friend"));
2011 Results.AddResult(
Result(
"mutable"));
2012 Results.AddResult(
Result(
"virtual"));
2020 if (LangOpts.CPlusPlus || LangOpts.C99)
2021 Results.AddResult(
Result(
"inline"));
2023 if (LangOpts.CPlusPlus20)
2024 Results.AddResult(
Result(
"consteval"));
2044 ResultBuilder &Results,
bool NeedAt);
2046 ResultBuilder &Results,
bool NeedAt);
2048 ResultBuilder &Results,
bool NeedAt);
2053 Results.getCodeCompletionTUInfo());
2054 Builder.AddTypedTextChunk(
"typedef");
2056 Builder.AddPlaceholderChunk(
"type");
2058 Builder.AddPlaceholderChunk(
"name");
2065 ResultBuilder &Results) {
2066 Builder.AddTypedTextChunk(
"using");
2068 Builder.AddPlaceholderChunk(
"name");
2070 Builder.AddPlaceholderChunk(
"type");
2093 return LangOpts.CPlusPlus;
2100 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
2103 llvm_unreachable(
"Invalid ParserCompletionContext!");
2113 Policy.CleanUglifiedParameters =
true;
2131 if (!
T.getLocalQualifiers()) {
2134 return BT->getNameAsCString(Policy);
2137 if (
const TagType *TagT = dyn_cast<TagType>(
T))
2138 if (
TagDecl *Tag = TagT->getDecl())
2139 if (!Tag->hasNameForLinkage()) {
2140 switch (Tag->getTagKind()) {
2142 return "struct <anonymous>";
2144 return "__interface <anonymous>";
2146 return "class <anonymous>";
2148 return "union <anonymous>";
2150 return "enum <anonymous>";
2157 T.getAsStringInternal(
Result, Policy);
2170 Builder.AddResultTypeChunk(
2172 Builder.AddTypedTextChunk(
"this");
2177 ResultBuilder &Results,
2179 if (!LangOpts.CPlusPlus11)
2182 Builder.AddTypedTextChunk(
"static_assert");
2184 Builder.AddPlaceholderChunk(
"expression");
2186 Builder.AddPlaceholderChunk(
"message");
2195 Sema &S = Results.getSema();
2196 const auto *CR = llvm::dyn_cast<CXXRecordDecl>(S.
CurContext);
2202 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
2203 for (
auto *Method : CR->methods()) {
2204 if (!Method->isVirtual() || !Method->getIdentifier())
2206 Overrides[Method->getName()].push_back(Method);
2209 for (
const auto &
Base : CR->bases()) {
2210 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
2213 for (
auto *Method : BR->methods()) {
2214 if (!Method->isVirtual() || !Method->getIdentifier())
2216 const auto it = Overrides.find(Method->getName());
2217 bool IsOverriden =
false;
2218 if (it != Overrides.end()) {
2219 for (
auto *MD : it->second) {
2237 false, CCContext, Policy);
2247 Scope *S,
Sema &SemaRef, ResultBuilder &Results) {
2255 if (Results.includeCodePatterns()) {
2257 Builder.AddTypedTextChunk(
"namespace");
2259 Builder.AddPlaceholderChunk(
"identifier");
2263 Builder.AddPlaceholderChunk(
"declarations");
2266 Results.AddResult(
Result(Builder.TakeString()));
2270 Builder.AddTypedTextChunk(
"namespace");
2272 Builder.AddPlaceholderChunk(
"name");
2274 Builder.AddPlaceholderChunk(
"namespace");
2276 Results.AddResult(
Result(Builder.TakeString()));
2279 Builder.AddTypedTextChunk(
"using namespace");
2281 Builder.AddPlaceholderChunk(
"identifier");
2283 Results.AddResult(
Result(Builder.TakeString()));
2286 Builder.AddTypedTextChunk(
"asm");
2288 Builder.AddPlaceholderChunk(
"string-literal");
2290 Results.AddResult(
Result(Builder.TakeString()));
2292 if (Results.includeCodePatterns()) {
2294 Builder.AddTypedTextChunk(
"template");
2296 Builder.AddPlaceholderChunk(
"declaration");
2297 Results.AddResult(
Result(Builder.TakeString()));
2308 if (!CurrentModule) {
2310 Builder.AddTypedTextChunk(
"module");
2313 Results.AddResult(
Result(Builder.TakeString()));
2318 if (!CurrentModule ||
2323 Builder.AddTypedTextChunk(
"module");
2325 Builder.AddPlaceholderChunk(
"name");
2328 Results.AddResult(
Result(Builder.TakeString()));
2333 if (!CurrentModule ||
2337 Builder.AddTypedTextChunk(
"import");
2339 Builder.AddPlaceholderChunk(
"name");
2342 Results.AddResult(
Result(Builder.TakeString()));
2345 if (CurrentModule &&
2349 Builder.AddTypedTextChunk(
"module");
2352 Builder.AddTypedTextChunk(
"private");
2355 Results.AddResult(
Result(Builder.TakeString()));
2360 if (!CurrentModule ||
2375 Builder.AddTypedTextChunk(
"using");
2377 Builder.AddPlaceholderChunk(
"qualifier");
2378 Builder.AddTextChunk(
"::");
2379 Builder.AddPlaceholderChunk(
"name");
2381 Results.AddResult(
Result(Builder.TakeString()));
2388 Builder.AddTypedTextChunk(
"using typename");
2390 Builder.AddPlaceholderChunk(
"qualifier");
2391 Builder.AddTextChunk(
"::");
2392 Builder.AddPlaceholderChunk(
"name");
2394 Results.AddResult(
Result(Builder.TakeString()));
2404 Builder.AddTypedTextChunk(
"public");
2405 if (IsNotInheritanceScope && Results.includeCodePatterns())
2407 Results.AddResult(
Result(Builder.TakeString()));
2410 Builder.AddTypedTextChunk(
"protected");
2411 if (IsNotInheritanceScope && Results.includeCodePatterns())
2413 Results.AddResult(
Result(Builder.TakeString()));
2416 Builder.AddTypedTextChunk(
"private");
2417 if (IsNotInheritanceScope && Results.includeCodePatterns())
2419 Results.AddResult(
Result(Builder.TakeString()));
2437 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
2439 Builder.AddTypedTextChunk(
"template");
2441 Builder.AddPlaceholderChunk(
"parameters");
2443 Results.AddResult(
Result(Builder.TakeString()));
2481 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
2483 Builder.AddTypedTextChunk(
"try");
2487 Builder.AddPlaceholderChunk(
"statements");
2491 Builder.AddTextChunk(
"catch");
2494 Builder.AddPlaceholderChunk(
"declaration");
2499 Builder.AddPlaceholderChunk(
"statements");
2502 Results.AddResult(
Result(Builder.TakeString()));
2507 if (Results.includeCodePatterns()) {
2509 Builder.AddTypedTextChunk(
"if");
2513 Builder.AddPlaceholderChunk(
"condition");
2515 Builder.AddPlaceholderChunk(
"expression");
2520 Builder.AddPlaceholderChunk(
"statements");
2523 Results.AddResult(
Result(Builder.TakeString()));
2526 Builder.AddTypedTextChunk(
"switch");
2530 Builder.AddPlaceholderChunk(
"condition");
2532 Builder.AddPlaceholderChunk(
"expression");
2537 Builder.AddPlaceholderChunk(
"cases");
2540 Results.AddResult(
Result(Builder.TakeString()));
2547 Builder.AddTypedTextChunk(
"case");
2549 Builder.AddPlaceholderChunk(
"expression");
2551 Results.AddResult(
Result(Builder.TakeString()));
2554 Builder.AddTypedTextChunk(
"default");
2556 Results.AddResult(
Result(Builder.TakeString()));
2559 if (Results.includeCodePatterns()) {
2561 Builder.AddTypedTextChunk(
"while");
2565 Builder.AddPlaceholderChunk(
"condition");
2567 Builder.AddPlaceholderChunk(
"expression");
2572 Builder.AddPlaceholderChunk(
"statements");
2575 Results.AddResult(
Result(Builder.TakeString()));
2578 Builder.AddTypedTextChunk(
"do");
2582 Builder.AddPlaceholderChunk(
"statements");
2585 Builder.AddTextChunk(
"while");
2588 Builder.AddPlaceholderChunk(
"expression");
2590 Results.AddResult(
Result(Builder.TakeString()));
2593 Builder.AddTypedTextChunk(
"for");
2597 Builder.AddPlaceholderChunk(
"init-statement");
2599 Builder.AddPlaceholderChunk(
"init-expression");
2602 Builder.AddPlaceholderChunk(
"condition");
2605 Builder.AddPlaceholderChunk(
"inc-expression");
2610 Builder.AddPlaceholderChunk(
"statements");
2613 Results.AddResult(
Result(Builder.TakeString()));
2617 Builder.AddTypedTextChunk(
"for");
2620 Builder.AddPlaceholderChunk(
"range-declaration");
2623 Builder.AddTextChunk(
"in");
2627 Builder.AddPlaceholderChunk(
"range-expression");
2632 Builder.AddPlaceholderChunk(
"statements");
2635 Results.AddResult(
Result(Builder.TakeString()));
2641 Builder.AddTypedTextChunk(
"continue");
2643 Results.AddResult(
Result(Builder.TakeString()));
2648 Builder.AddTypedTextChunk(
"break");
2650 Results.AddResult(
Result(Builder.TakeString()));
2655 if (
const auto *Function = dyn_cast<FunctionDecl>(SemaRef.
CurContext)) {
2656 if (!Function->getType().isNull())
2657 ReturnType = Function->getReturnType();
2658 }
else if (
const auto *Method =
2659 dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
2660 ReturnType = Method->getReturnType();
2665 Builder.AddTypedTextChunk(
"return");
2667 Results.AddResult(
Result(Builder.TakeString()));
2669 assert(!ReturnType.
isNull());
2671 Builder.AddTypedTextChunk(
"return");
2673 Builder.AddPlaceholderChunk(
"expression");
2675 Results.AddResult(
Result(Builder.TakeString()));
2678 Builder.AddTypedTextChunk(
"co_return");
2680 Builder.AddPlaceholderChunk(
"expression");
2682 Results.AddResult(
Result(Builder.TakeString()));
2686 Builder.AddTypedTextChunk(
"return true");
2688 Results.AddResult(
Result(Builder.TakeString()));
2690 Builder.AddTypedTextChunk(
"return false");
2692 Results.AddResult(
Result(Builder.TakeString()));
2697 Builder.AddTypedTextChunk(
"return nullptr");
2699 Results.AddResult(
Result(Builder.TakeString()));
2704 Builder.AddTypedTextChunk(
"goto");
2706 Builder.AddPlaceholderChunk(
"label");
2708 Results.AddResult(
Result(Builder.TakeString()));
2711 Builder.AddTypedTextChunk(
"using namespace");
2713 Builder.AddPlaceholderChunk(
"identifier");
2715 Results.AddResult(
Result(Builder.TakeString()));
2732 Builder.AddTypedTextChunk(
"__bridge");
2734 Builder.AddPlaceholderChunk(
"type");
2736 Builder.AddPlaceholderChunk(
"expression");
2737 Results.AddResult(
Result(Builder.TakeString()));
2740 Builder.AddTypedTextChunk(
"__bridge_transfer");
2742 Builder.AddPlaceholderChunk(
"Objective-C type");
2744 Builder.AddPlaceholderChunk(
"expression");
2745 Results.AddResult(
Result(Builder.TakeString()));
2748 Builder.AddTypedTextChunk(
"__bridge_retained");
2750 Builder.AddPlaceholderChunk(
"CF type");
2752 Builder.AddPlaceholderChunk(
"expression");
2753 Results.AddResult(
Result(Builder.TakeString()));
2764 Builder.AddResultTypeChunk(
"bool");
2765 Builder.AddTypedTextChunk(
"true");
2766 Results.AddResult(
Result(Builder.TakeString()));
2769 Builder.AddResultTypeChunk(
"bool");
2770 Builder.AddTypedTextChunk(
"false");
2771 Results.AddResult(
Result(Builder.TakeString()));
2775 Builder.AddTypedTextChunk(
"dynamic_cast");
2777 Builder.AddPlaceholderChunk(
"type");
2780 Builder.AddPlaceholderChunk(
"expression");
2782 Results.AddResult(
Result(Builder.TakeString()));
2786 Builder.AddTypedTextChunk(
"static_cast");
2788 Builder.AddPlaceholderChunk(
"type");
2791 Builder.AddPlaceholderChunk(
"expression");
2793 Results.AddResult(
Result(Builder.TakeString()));
2796 Builder.AddTypedTextChunk(
"reinterpret_cast");
2798 Builder.AddPlaceholderChunk(
"type");
2801 Builder.AddPlaceholderChunk(
"expression");
2803 Results.AddResult(
Result(Builder.TakeString()));
2806 Builder.AddTypedTextChunk(
"const_cast");
2808 Builder.AddPlaceholderChunk(
"type");
2811 Builder.AddPlaceholderChunk(
"expression");
2813 Results.AddResult(
Result(Builder.TakeString()));
2817 Builder.AddResultTypeChunk(
"std::type_info");
2818 Builder.AddTypedTextChunk(
"typeid");
2820 Builder.AddPlaceholderChunk(
"expression-or-type");
2822 Results.AddResult(
Result(Builder.TakeString()));
2826 Builder.AddTypedTextChunk(
"new");
2828 Builder.AddPlaceholderChunk(
"type");
2830 Builder.AddPlaceholderChunk(
"expressions");
2832 Results.AddResult(
Result(Builder.TakeString()));
2835 Builder.AddTypedTextChunk(
"new");
2837 Builder.AddPlaceholderChunk(
"type");
2839 Builder.AddPlaceholderChunk(
"size");
2842 Builder.AddPlaceholderChunk(
"expressions");
2844 Results.AddResult(
Result(Builder.TakeString()));
2847 Builder.AddResultTypeChunk(
"void");
2848 Builder.AddTypedTextChunk(
"delete");
2850 Builder.AddPlaceholderChunk(
"expression");
2851 Results.AddResult(
Result(Builder.TakeString()));
2854 Builder.AddResultTypeChunk(
"void");
2855 Builder.AddTypedTextChunk(
"delete");
2860 Builder.AddPlaceholderChunk(
"expression");
2861 Results.AddResult(
Result(Builder.TakeString()));
2865 Builder.AddResultTypeChunk(
"void");
2866 Builder.AddTypedTextChunk(
"throw");
2868 Builder.AddPlaceholderChunk(
"expression");
2869 Results.AddResult(
Result(Builder.TakeString()));
2876 Builder.AddResultTypeChunk(
"std::nullptr_t");
2877 Builder.AddTypedTextChunk(
"nullptr");
2878 Results.AddResult(
Result(Builder.TakeString()));
2881 Builder.AddResultTypeChunk(
"size_t");
2882 Builder.AddTypedTextChunk(
"alignof");
2884 Builder.AddPlaceholderChunk(
"type");
2886 Results.AddResult(
Result(Builder.TakeString()));
2889 Builder.AddResultTypeChunk(
"bool");
2890 Builder.AddTypedTextChunk(
"noexcept");
2892 Builder.AddPlaceholderChunk(
"expression");
2894 Results.AddResult(
Result(Builder.TakeString()));
2897 Builder.AddResultTypeChunk(
"size_t");
2898 Builder.AddTypedTextChunk(
"sizeof...");
2900 Builder.AddPlaceholderChunk(
"parameter-pack");
2902 Results.AddResult(
Result(Builder.TakeString()));
2907 Builder.AddTypedTextChunk(
"co_await");
2909 Builder.AddPlaceholderChunk(
"expression");
2910 Results.AddResult(
Result(Builder.TakeString()));
2913 Builder.AddTypedTextChunk(
"co_yield");
2915 Builder.AddPlaceholderChunk(
"expression");
2916 Results.AddResult(
Result(Builder.TakeString()));
2919 Builder.AddResultTypeChunk(
"bool");
2920 Builder.AddTypedTextChunk(
"requires");
2923 Builder.AddPlaceholderChunk(
"parameters");
2928 Builder.AddPlaceholderChunk(
"requirements");
2931 Results.AddResult(
Result(Builder.TakeString()));
2935 Builder.AddTypedTextChunk(
"requires");
2937 Builder.AddPlaceholderChunk(
"expression");
2939 Results.AddResult(
Result(Builder.TakeString()));
2949 if (ID->getSuperClass()) {
2950 std::string SuperType;
2951 SuperType = ID->getSuperClass()->getNameAsString();
2952 if (Method->isInstanceMethod())
2955 Builder.AddResultTypeChunk(Allocator.
CopyString(SuperType));
2956 Builder.AddTypedTextChunk(
"super");
2957 Results.AddResult(
Result(Builder.TakeString()));
2966 Builder.AddResultTypeChunk(
"size_t");
2968 Builder.AddTypedTextChunk(
"alignof");
2970 Builder.AddTypedTextChunk(
"_Alignof");
2972 Builder.AddPlaceholderChunk(
"type");
2974 Results.AddResult(
Result(Builder.TakeString()));
2979 Builder.AddResultTypeChunk(
"nullptr_t");
2980 Builder.AddTypedTextChunk(
"nullptr");
2981 Results.AddResult(
Result(Builder.TakeString()));
2985 Builder.AddResultTypeChunk(
"size_t");
2986 Builder.AddTypedTextChunk(
"sizeof");
2988 Builder.AddPlaceholderChunk(
"expression-or-type");
2990 Results.AddResult(
Result(Builder.TakeString()));
3003 Results.AddResult(
Result(
"operator"));
3023 T = Function->getReturnType();
3024 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3025 if (!BaseType.isNull())
3026 T = Method->getSendResultType(BaseType);
3028 T = Method->getReturnType();
3029 }
else if (
const auto *
Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
3030 T = Context.getCanonicalTagType(
3034 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
3035 if (!BaseType.isNull())
3036 T = Ivar->getUsageType(BaseType);
3038 T = Ivar->getType();
3039 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
3041 }
else if (
const auto *Property = dyn_cast<ObjCPropertyDecl>(ND)) {
3042 if (!BaseType.isNull())
3043 T = Property->getUsageType(BaseType);
3045 T = Property->getType();
3048 if (
T.isNull() || Context.hasSameType(
T, Context.DependentTy))
3051 Result.AddResultTypeChunk(
3058 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
3059 if (Sentinel->getSentinel() == 0) {
3061 Result.AddTextChunk(
", nil");
3063 Result.AddTextChunk(
", NULL");
3065 Result.AddTextChunk(
", (void*)0");
3085 if (
auto nullability = AttributedType::stripOuterNullability(
Type)) {
3086 switch (*nullability) {
3096 Result +=
"null_unspecified ";
3100 llvm_unreachable(
"Not supported as a context-sensitive keyword!");
3117 bool SuppressBlock =
false) {
3123 if (!SuppressBlock) {
3126 TypedefTL.getDecl()->getTypeSourceInfo()) {
3139 TL = AttrTL.getModifiedLoc();
3158 bool SuppressBlockName =
false,
bool SuppressBlock =
false,
3163 bool SuppressName =
false,
bool SuppressBlock =
false,
3171 if (
const auto *PVD = dyn_cast<ParmVarDecl>(Param))
3172 ObjCQual = PVD->getObjCDeclQualifier();
3174 if (Param->getType()->isDependentType() ||
3175 !Param->getType()->isBlockPointerType()) {
3180 if (Param->getIdentifier() && !ObjCMethodParam && !SuppressName)
3181 Result = std::string(Param->getIdentifier()->deuglifiedName());
3185 Type =
Type.substObjCTypeArgs(Param->getASTContext(), *ObjCSubsts,
3187 if (ObjCMethodParam) {
3190 if (Param->getIdentifier() && !SuppressName)
3191 Result += Param->getIdentifier()->deuglifiedName();
3206 if (!
Block && ObjCMethodParam &&
3209 ->findPropertyDecl(
false))
3218 if (!ObjCMethodParam && Param->getIdentifier())
3219 Result = std::string(Param->getIdentifier()->deuglifiedName());
3223 if (ObjCMethodParam) {
3228 if (
Result.back() !=
')')
3230 if (Param->getIdentifier())
3231 Result += Param->getIdentifier()->deuglifiedName();
3242 false, SuppressBlock,
3258 bool SuppressBlockName,
bool SuppressBlock,
3266 if (!ResultType->
isVoidType() || SuppressBlock)
3271 if (!BlockProto ||
Block.getNumParams() == 0) {
3278 for (
unsigned I = 0, N =
Block.getNumParams(); I != N; ++I) {
3291 if (SuppressBlock) {
3294 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3303 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3313 const SourceRange SrcRange = Param->getDefaultArgRange();
3323 if (srcText.empty() || srcText ==
"=") {
3329 std::string DefValue(srcText.str());
3332 if (DefValue.at(0) !=
'=') {
3336 return " = " + DefValue;
3338 return " " + DefValue;
3345 unsigned Start = 0,
bool InOptional =
false,
bool FunctionCanBeCall =
true,
3346 bool IsInDeclarationContext =
false) {
3347 bool FirstParameter =
true;
3348 bool AsInformativeChunk = !(FunctionCanBeCall || IsInDeclarationContext);
3350 const FunctionDecl *BetterSignatureDecl = BetterSignature(Function, Start);
3352 for (
unsigned P = Start, N = Function->getNumParams(); P != N; ++P) {
3355 if (Param->hasDefaultArg() && !InOptional && !IsInDeclarationContext &&
3356 !AsInformativeChunk) {
3360 Result.getCodeCompletionTUInfo());
3361 if (!FirstParameter)
3371 if (FirstParameter && Param->isExplicitObjectParameter()) {
3376 FirstParameter =
false;
3378 if (AsInformativeChunk)
3379 Result.AddInformativeChunk(
", ");
3388 std::string DefaultValue;
3389 if (Param->hasDefaultArg()) {
3390 if (IsInDeclarationContext)
3398 if (Function->isVariadic() && P == N - 1)
3399 PlaceholderStr +=
", ...";
3402 if (AsInformativeChunk)
3403 Result.AddInformativeChunk(
3404 Result.getAllocator().CopyString(PlaceholderStr));
3405 else if (IsInDeclarationContext) {
3406 Result.AddTextChunk(
Result.getAllocator().CopyString(PlaceholderStr));
3407 if (DefaultValue.length() != 0)
3408 Result.AddInformativeChunk(
3409 Result.getAllocator().CopyString(DefaultValue));
3411 Result.AddPlaceholderChunk(
3412 Result.getAllocator().CopyString(PlaceholderStr));
3416 if (Proto->isVariadic()) {
3417 if (Proto->getNumParams() == 0)
3418 Result.AddPlaceholderChunk(
"...");
3428 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false,
3429 bool AsInformativeChunk =
false) {
3430 bool FirstParameter =
true;
3439 PEnd = Params->
begin() + MaxParameters;
3442 bool HasDefaultArg =
false;
3443 std::string PlaceholderStr;
3445 if (TTP->wasDeclaredWithTypename())
3446 PlaceholderStr =
"typename";
3447 else if (
const auto *TC = TTP->getTypeConstraint()) {
3448 llvm::raw_string_ostream OS(PlaceholderStr);
3449 TC->print(OS, Policy);
3451 PlaceholderStr =
"class";
3453 if (TTP->getIdentifier()) {
3454 PlaceholderStr +=
' ';
3455 PlaceholderStr += TTP->getIdentifier()->deuglifiedName();
3458 HasDefaultArg = TTP->hasDefaultArgument();
3460 dyn_cast<NonTypeTemplateParmDecl>(*P)) {
3461 if (NTTP->getIdentifier())
3462 PlaceholderStr = std::string(NTTP->getIdentifier()->deuglifiedName());
3463 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
3464 HasDefaultArg = NTTP->hasDefaultArgument();
3471 PlaceholderStr =
"template<...> class";
3473 PlaceholderStr +=
' ';
3480 if (HasDefaultArg && !InDefaultArg && !AsInformativeChunk) {
3484 Result.getCodeCompletionTUInfo());
3485 if (!FirstParameter)
3488 P - Params->
begin(),
true);
3493 InDefaultArg =
false;
3496 FirstParameter =
false;
3498 if (AsInformativeChunk)
3499 Result.AddInformativeChunk(
", ");
3504 if (AsInformativeChunk)
3505 Result.AddInformativeChunk(
3506 Result.getAllocator().CopyString(PlaceholderStr));
3508 Result.AddPlaceholderChunk(
3509 Result.getAllocator().CopyString(PlaceholderStr));
3517 bool QualifierIsInformative,
3523 std::string PrintedNNS;
3525 llvm::raw_string_ostream OS(PrintedNNS);
3526 Qualifier.print(OS, Policy);
3528 if (QualifierIsInformative)
3529 Result.AddInformativeChunk(
Result.getAllocator().CopyString(PrintedNNS));
3531 Result.AddTextChunk(
Result.getAllocator().CopyString(PrintedNNS));
3536 bool AsInformativeChunk =
true) {
3541 if (AsInformativeChunk)
3542 Result.AddInformativeChunk(
" const");
3544 Result.AddTextChunk(
" const");
3549 if (AsInformativeChunk)
3550 Result.AddInformativeChunk(
" volatile");
3552 Result.AddTextChunk(
" volatile");
3557 if (AsInformativeChunk)
3558 Result.AddInformativeChunk(
" restrict");
3560 Result.AddTextChunk(
" restrict");
3565 std::string QualsStr;
3567 QualsStr +=
" const";
3569 QualsStr +=
" volatile";
3571 QualsStr +=
" restrict";
3573 if (AsInformativeChunk)
3574 Result.AddInformativeChunk(
Result.getAllocator().CopyString(QualsStr));
3576 Result.AddTextChunk(
Result.getAllocator().CopyString(QualsStr));
3582 bool AsInformativeChunks =
true) {
3583 if (
auto *CxxMethodDecl = llvm::dyn_cast_if_present<CXXMethodDecl>(Function);
3584 CxxMethodDecl && CxxMethodDecl->hasCXXExplicitFunctionObjectParameter()) {
3586 const auto Quals = CxxMethodDecl->getFunctionObjectParameterType();
3587 if (!Quals.hasQualifiers())
3593 if (!Proto || !Proto->getMethodQuals())
3608 switch (ExceptInfo.Type) {
3611 NameAndSignature +=
" noexcept";
3629 const char *OperatorName =
nullptr;
3632 case OO_Conditional:
3634 OperatorName =
"operator";
3637#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
3639 OperatorName = "operator" Spelling; \
3641#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly)
3642#include "clang/Basic/OperatorKinds.def"
3645 OperatorName =
"operator new";
3648 OperatorName =
"operator delete";
3651 OperatorName =
"operator new[]";
3653 case OO_Array_Delete:
3654 OperatorName =
"operator delete[]";
3657 OperatorName =
"operator()";
3660 OperatorName =
"operator[]";
3663 Result.AddTypedTextChunk(OperatorName);
3671 Result.AddTypedTextChunk(
3688 Result.AddTypedTextChunk(
3693 Result.AddTypedTextChunk(
3694 Result.getAllocator().CopyString(
Record->getNameAsString()));
3708 bool IncludeBriefComments) {
3710 CCTUInfo, IncludeBriefComments);
3722 return Result.TakeString();
3733 Result.AddPlaceholderChunk(
"...");
3747 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3752 Result.AddPlaceholderChunk(
3753 Result.getAllocator().CopyString((*A)->getName()));
3756 return Result.TakeString();
3768 bool IncludeBriefComments) {
3784 Result.addBriefComment(RC->getBriefText(Ctx));
3794 return Result.TakeString();
3798 PP, Ctx,
Result, IncludeBriefComments, CCContext, Policy);
3802 std::string &BeforeName,
3803 std::string &NameAndSignature) {
3804 bool SeenTypedChunk =
false;
3805 for (
auto &Chunk : CCS) {
3807 assert(SeenTypedChunk &&
"optional parameter before name");
3814 NameAndSignature += Chunk.Text;
3816 BeforeName += Chunk.Text;
3828 std::string BeforeName;
3829 std::string NameAndSignature;
3835 const auto *VirtualFunc = dyn_cast<FunctionDecl>(
Declaration);
3836 assert(VirtualFunc &&
"overridden decl must be a function");
3839 NameAndSignature +=
" override";
3841 Result.AddTextChunk(
Result.getAllocator().CopyString(BeforeName));
3843 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(NameAndSignature));
3844 return Result.TakeString();
3850 const auto *VD = dyn_cast<VarDecl>(ND);
3853 const auto *
RecordDecl = VD->getType()->getAsCXXRecordDecl();
3866 if (IncludeBriefComments) {
3869 Result.addBriefComment(RC->getBriefText(Ctx));
3874 Result.AddTypedTextChunk(
3876 Result.AddTextChunk(
"::");
3877 return Result.TakeString();
3881 Result.AddAnnotation(
Result.getAllocator().CopyString(I->getAnnotation()));
3889 if (InsertParameters)
3892 Result.AddInformativeChunk(
"(");
3897 if (InsertParameters)
3900 Result.AddInformativeChunk(
")");
3905 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND)) {
3906 AddFunctionTypeAndResult(
Function);
3907 return Result.TakeString();
3910 if (
const auto *CallOperator =
3912 AddFunctionTypeAndResult(CallOperator);
3913 return Result.TakeString();
3919 dyn_cast<FunctionTemplateDecl>(ND)) {
3930 llvm::SmallBitVector
Deduced(FunTmpl->getTemplateParameters()->size());
3935 unsigned LastDeducibleArgument;
3936 for (LastDeducibleArgument =
Deduced.size(); LastDeducibleArgument > 0;
3937 --LastDeducibleArgument) {
3938 if (!
Deduced[LastDeducibleArgument - 1]) {
3942 bool HasDefaultArg =
false;
3943 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3944 LastDeducibleArgument - 1);
3946 HasDefaultArg = TTP->hasDefaultArgument();
3948 dyn_cast<NonTypeTemplateParmDecl>(Param))
3949 HasDefaultArg = NTTP->hasDefaultArgument();
3977 Result.AddInformativeChunk(
"<");
3979 Ctx, Policy, FunTmpl,
Result, LastDeducibleArgument, 0,
3986 Result.AddInformativeChunk(
">");
3991 if (InsertParameters)
3994 Result.AddInformativeChunk(
"(");
3999 if (InsertParameters)
4002 Result.AddInformativeChunk(
")");
4004 return Result.TakeString();
4007 if (
const auto *
Template = dyn_cast<TemplateDecl>(ND)) {
4010 Result.AddTypedTextChunk(
4015 return Result.TakeString();
4018 if (
const auto *
Method = dyn_cast<ObjCMethodDecl>(ND)) {
4021 Result.AddTypedTextChunk(
4023 return Result.TakeString();
4029 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(SelName));
4031 Result.AddInformativeChunk(
Result.getAllocator().CopyString(SelName));
4035 if (
Method->param_size() == 1)
4036 Result.AddTypedTextChunk(
"");
4042 PEnd =
Method->param_end();
4043 P != PEnd && Idx < Sel.
getNumArgs(); (
void)++P, ++Idx) {
4062 QualType ParamType = (*P)->getType();
4063 std::optional<ArrayRef<QualType>> ObjCSubsts;
4079 Arg += II->getName();
4082 if (
Method->isVariadic() && (P + 1) == PEnd)
4086 Result.AddTextChunk(
Result.getAllocator().CopyString(Arg));
4088 Result.AddInformativeChunk(
Result.getAllocator().CopyString(Arg));
4090 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
4093 if (
Method->isVariadic()) {
4094 if (
Method->param_size() == 0) {
4096 Result.AddTextChunk(
", ...");
4098 Result.AddInformativeChunk(
", ...");
4100 Result.AddPlaceholderChunk(
", ...");
4106 return Result.TakeString();
4113 Result.AddTypedTextChunk(
4115 return Result.TakeString();
4126 const auto *M = dyn_cast<ObjCMethodDecl>(ND);
4138 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
4139 if (!M || !M->isPropertyAccessor())
4162 auto FDecl =
Result.getFunction();
4165 if (ArgIndex < FDecl->getNumParams())
4173 unsigned CurrentArg) {
4174 unsigned ChunkIndex = 0;
4175 auto AddChunk = [&](llvm::StringRef Placeholder) {
4178 const char *
Copy =
Result.getAllocator().CopyString(Placeholder);
4179 if (ChunkIndex == CurrentArg)
4187 if (
auto *CRD = llvm::dyn_cast<CXXRecordDecl>(RD)) {
4188 for (
const auto &
Base : CRD->bases())
4189 AddChunk(
Base.getType().getAsString(Policy));
4191 for (
const auto &Field : RD->
fields())
4201 unsigned CurrentArg,
unsigned Start = 0,
bool InOptional =
false) {
4207 bool FirstParameter =
true;
4208 unsigned NumParams =
4209 Function ? Function->getNumParams() :
Prototype->getNumParams();
4211 Function ? BetterSignature(Function, Start) :
nullptr;
4213 for (
unsigned P = Start; P != NumParams; ++P) {
4214 if (Function && Function->getParamDecl(P)->hasDefaultArg() && !InOptional) {
4218 Result.getCodeCompletionTUInfo());
4219 if (!FirstParameter)
4223 PrototypeLoc, Opt, CurrentArg, P,
4232 if (Function && FirstParameter &&
4233 Function->getParamDecl(P)->isExplicitObjectParameter()) {
4238 FirstParameter =
false;
4245 std::string Placeholder;
4246 assert(P < Prototype->getNumParams());
4247 if (Function || PrototypeLoc) {
4251 if (Param->hasDefaultArg())
4253 Context.getLangOpts());
4255 Placeholder =
Prototype->getParamType(P).getAsString(Policy);
4258 if (P == CurrentArg)
4259 Result.AddCurrentParameterChunk(
4260 Result.getAllocator().CopyString(Placeholder));
4262 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Placeholder));
4267 Result.getCodeCompletionTUInfo());
4268 if (!FirstParameter)
4271 if (CurrentArg < NumParams)
4283 if (
const auto *
Type = dyn_cast<TemplateTypeParmDecl>(Param)) {
4285 }
else if (
const auto *
NonType = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4287 }
else if (
const auto *
Template = dyn_cast<TemplateTemplateParmDecl>(Param)) {
4291 llvm::raw_string_ostream OS(
Result);
4292 Param->print(OS, Policy);
4298 if (
const auto *CTD = dyn_cast<ClassTemplateDecl>(TD))
4299 return CTD->getTemplatedDecl()->getKindName().str();
4300 if (
const auto *VTD = dyn_cast<VarTemplateDecl>(TD))
4301 return VTD->getTemplatedDecl()->getType().getAsString(Policy);
4302 if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(TD))
4303 return FTD->getTemplatedDecl()->getReturnType().getAsString(Policy);
4318 Builder.getCodeCompletionTUInfo());
4320 if (!ResultType.empty())
4321 Builder.AddResultTypeChunk(Builder.getAllocator().CopyString(ResultType));
4322 Builder.AddTextChunk(
4328 for (
unsigned I = 0; I < Params.size(); ++I) {
4330 std::string Placeholder =
4333 Current = &OptionalBuilder;
4342 if (Current == &OptionalBuilder)
4348 Builder.AddInformativeChunk(
"()");
4349 return Builder.TakeString();
4356 bool Braced)
const {
4380 if (IncludeBriefComments) {
4387 llvm::raw_string_ostream OS(Name);
4389 Result.AddTextChunk(
Result.getAllocator().CopyString(Name));
4392 Result.AddResultTypeChunk(
Result.getAllocator().CopyString(
4407 return Result.TakeString();
4412 bool PreferredTypeIsPointer) {
4416 if (MacroName ==
"nil" || MacroName ==
"NULL" || MacroName ==
"Nil") {
4418 if (PreferredTypeIsPointer)
4422 else if (MacroName ==
"YES" || MacroName ==
"NO" || MacroName ==
"true" ||
4423 MacroName ==
"false")
4426 else if (MacroName ==
"bool")
4439 case Decl::EnumConstant:
4443 case Decl::Function:
4445 case Decl::ObjCCategory:
4447 case Decl::ObjCCategoryImpl:
4449 case Decl::ObjCImplementation:
4452 case Decl::ObjCInterface:
4454 case Decl::ObjCIvar:
4456 case Decl::ObjCMethod:
4460 case Decl::CXXMethod:
4462 case Decl::CXXConstructor:
4464 case Decl::CXXDestructor:
4466 case Decl::CXXConversion:
4468 case Decl::ObjCProperty:
4470 case Decl::ObjCProtocol:
4476 case Decl::TypeAlias:
4478 case Decl::TypeAliasTemplate:
4482 case Decl::Namespace:
4484 case Decl::NamespaceAlias:
4486 case Decl::TemplateTypeParm:
4488 case Decl::NonTypeTemplateParm:
4490 case Decl::TemplateTemplateParm:
4492 case Decl::FunctionTemplate:
4494 case Decl::ClassTemplate:
4496 case Decl::AccessSpec:
4498 case Decl::ClassTemplatePartialSpecialization:
4500 case Decl::UsingDirective:
4502 case Decl::StaticAssert:
4505 case Decl::FriendTemplate:
4507 case Decl::TranslationUnit:
4511 case Decl::UnresolvedUsingValue:
4512 case Decl::UnresolvedUsingTypename:
4515 case Decl::UsingEnum:
4518 case Decl::ObjCPropertyImpl:
4526 llvm_unreachable(
"Unexpected Kind!");
4531 case Decl::ObjCTypeParam:
4537 case Decl::LinkageSpec:
4541 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
4542 switch (TD->getTagKind()) {
4560 bool LoadExternal,
bool IncludeUndefined,
4561 bool TargetTypeIsPointer =
false) {
4564 Results.EnterNewScope();
4566 for (
const auto &M : PP.
macros(LoadExternal)) {
4568 if (IncludeUndefined || MD) {
4576 TargetTypeIsPointer)));
4580 Results.ExitScope();
4584 ResultBuilder &Results) {
4587 Results.EnterNewScope();
4591 if (LangOpts.C99 || LangOpts.CPlusPlus11)
4593 Results.ExitScope();
4600 unsigned NumResults) {
4605static CodeCompletionContext
4663 llvm_unreachable(
"Invalid ParserCompletionContext!");
4675 ResultBuilder &Results) {
4681 CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(CurContext);
4682 if (!Method || !Method->isVirtual())
4687 for (
auto *P : Method->parameters())
4688 if (!P->getDeclName())
4694 Results.getCodeCompletionTUInfo());
4695 if (Overridden->getCanonicalDecl() == Method->getCanonicalDecl())
4701 S.
Context, CurContext, Overridden->getDeclContext());
4704 llvm::raw_string_ostream OS(Str);
4705 NNS.
print(OS, Policy);
4706 Builder.AddTextChunk(Results.getAllocator().CopyString(Str));
4708 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
4711 Builder.AddTypedTextChunk(
4712 Results.getAllocator().CopyString(Overridden->getNameAsString()));
4714 bool FirstParam =
true;
4715 for (
auto *P : Method->parameters()) {
4721 Builder.AddPlaceholderChunk(
4722 Results.getAllocator().CopyString(P->getIdentifier()->getName()));
4728 Results.Ignore(Overridden);
4738 Results.EnterNewScope();
4746 SemaRef.PP.getHeaderSearchInfo().collectAllModules(Modules);
4753 StringRef CurrentPrimary;
4755 CurrentPrimary = CurrentModule->getPrimaryModuleInterfaceName();
4756 else if (
SemaRef.PP.isInNamedModule())
4757 CurrentPrimary =
SemaRef.PP.getNamedModuleName().split(
':').first;
4758 llvm::StringSet<> AddedModules;
4759 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
4762 if (Modules[I]->isModulePartition()) {
4763 if (CurrentPrimary.empty() ||
4764 Modules[I]->getPrimaryModuleInterfaceName() != CurrentPrimary)
4767 Builder.AddTypedTextChunk(
4768 Builder.getAllocator().CopyString(Modules[I]->Name));
4769 Results.AddResult(
Result(
4773 AddedModules.insert(Modules[I]->Name);
4778 for (
const auto &Entry :
SemaRef.PP.getHeaderSearchInfo()
4779 .getHeaderSearchOpts()
4780 .PrebuiltModuleFiles) {
4781 if (AddedModules.count(Entry.first))
4783 StringRef Name = Entry.first;
4785 if (
auto [Primary, Partition] = Name.split(
':'); !Partition.empty()) {
4786 if (CurrentPrimary.empty() || Primary != CurrentPrimary)
4789 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Name));
4802 Builder.AddTypedTextChunk(
4803 Builder.getAllocator().CopyString(Submodule->Name));
4804 Results.AddResult(
Result(
4811 Results.ExitScope();
4813 Results.getCompletionContext(), Results.data(),
4822 Results.EnterNewScope();
4827 switch (CompletionContext) {
4837 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
4847 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4849 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4860 auto ThisType =
SemaRef.getCurrentThisType();
4861 if (ThisType.isNull()) {
4863 if (
auto *MethodDecl = llvm::dyn_cast_if_present<CXXMethodDecl>(
4864 SemaRef.getCurFunctionDecl()))
4865 Results.setExplicitObjectMemberFn(
4866 MethodDecl->isExplicitObjectMemberFunction());
4870 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
4874 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
4875 SemaRef.LookupVisibleDecls(S,
SemaRef.LookupOrdinaryName, Consumer,
4880 Results.ExitScope();
4882 switch (CompletionContext) {
4910 Results.getCompletionContext(), Results.data(),
4917 bool AtArgumentExpression,
bool IsSuper,
4918 ResultBuilder &Results);
4921 bool AllowNonIdentifiers,
4922 bool AllowNestedNameSpecifiers) {
4924 ResultBuilder Results(
4927 AllowNestedNameSpecifiers
4932 Results.EnterNewScope();
4935 Results.AddResult(
Result(
"const"));
4936 Results.AddResult(
Result(
"volatile"));
4938 Results.AddResult(
Result(
"restrict"));
4944 Results.AddResult(
"final");
4946 if (AllowNonIdentifiers) {
4947 Results.AddResult(
Result(
"operator"));
4951 if (AllowNestedNameSpecifiers) {
4952 Results.allowNestedNameSpecifiers();
4953 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
4954 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
4958 Results.setFilter(
nullptr);
4961 Results.ExitScope();
4967 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
4978 if (!
T.get().isNull() &&
T.get()->isObjCObjectOrInterfaceType())
4986 Results.getCompletionContext(), Results.data(),
4991 if (
Scope ==
"clang")
4999 if (
Scope ==
"_Clang")
5001 if (
Scope ==
"__gnu__")
5025 llvm::StringRef InScopeName;
5026 bool InScopeUnderscore =
false;
5028 InScopeName = InScope->
getName();
5030 InScopeName = NoUnderscore;
5031 InScopeUnderscore =
true;
5038 llvm::DenseSet<llvm::StringRef> FoundScopes;
5040 if (A.IsTargetSpecific &&
5045 for (
const auto &S : A.Spellings) {
5046 if (S.Syntax != Syntax)
5048 llvm::StringRef Name = S.NormalizedFullName;
5049 llvm::StringRef
Scope;
5052 std::tie(
Scope, Name) = Name.split(
"::");
5054 std::swap(Name,
Scope);
5060 if (!
Scope.empty() && FoundScopes.insert(
Scope).second) {
5071 if (!InScopeName.empty()) {
5072 if (
Scope != InScopeName)
5077 auto Add = [&](llvm::StringRef
Scope, llvm::StringRef Name,
5080 Results.getCodeCompletionTUInfo());
5082 if (!
Scope.empty()) {
5091 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
Text));
5093 if (!A.ArgNames.empty()) {
5096 for (
const char *Arg : A.ArgNames) {
5100 Builder.AddPlaceholderChunk(Arg);
5105 Results.AddResult(Builder.TakeString());
5112 if (!InScopeUnderscore)
5113 Add(
Scope, Name,
false);
5118 if (!(InScope && !InScopeUnderscore) && SyntaxSupportsGuards) {
5119 if (
Scope.empty()) {
5120 Add(
Scope, Name,
true);
5125 Add(GuardedScope, Name,
true);
5135 for (
const auto &Entry : ParsedAttrInfoRegistry::entries())
5136 AddCompletions(*Entry.instantiate());
5139 Results.getCompletionContext(), Results.data(),
5158struct CoveredEnumerators {
5166 const CoveredEnumerators &Enumerators) {
5168 if (Context.getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) {
5175 Results.EnterNewScope();
5176 for (
auto *E :
Enum->enumerators()) {
5177 if (Enumerators.Seen.count(E))
5181 Results.AddResult(R, CurContext,
nullptr,
false);
5183 Results.ExitScope();
5189 assert(!
T.isNull());
5202 if (
T->isPointerType())
5203 T =
T->getPointeeType();
5212 if (!Results.includeCodePatterns())
5215 Results.getCodeCompletionTUInfo());
5220 if (!Parameters.empty()) {
5229 constexpr llvm::StringLiteral NamePlaceholder =
"!#!NAME_GOES_HERE!#!";
5230 std::string
Type = std::string(NamePlaceholder);
5232 llvm::StringRef Prefix, Suffix;
5233 std::tie(Prefix, Suffix) = llvm::StringRef(
Type).split(NamePlaceholder);
5234 Prefix = Prefix.rtrim();
5235 Suffix = Suffix.ltrim();
5258 ResultBuilder Results(
5262 Data.IsParenthesized
5265 Data.PreferredType));
5268 if (
Data.ObjCCollection)
5269 Results.setFilter(&ResultBuilder::IsObjCCollection);
5270 else if (
Data.IntegralConstantExpression)
5271 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
5273 Results.setFilter(&ResultBuilder::IsOrdinaryName);
5275 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
5277 if (!
Data.PreferredType.isNull())
5278 Results.setPreferredType(
Data.PreferredType.getNonReferenceType());
5281 for (
unsigned I = 0, N =
Data.IgnoreDecls.size(); I != N; ++I)
5282 Results.Ignore(
Data.IgnoreDecls[I]);
5284 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
5285 Consumer.setIsAddressOfOperand(IsAddressOfOperand);
5290 Results.EnterNewScope();
5292 Results.ExitScope();
5294 bool PreferredTypeIsPointer =
false;
5295 if (!
Data.PreferredType.isNull()) {
5296 PreferredTypeIsPointer =
Data.PreferredType->isAnyPointerType() ||
5297 Data.PreferredType->isMemberPointerType() ||
5298 Data.PreferredType->isBlockPointerType();
5299 if (
auto *
Enum =
Data.PreferredType->getAsEnumDecl()) {
5303 CoveredEnumerators());
5308 !
Data.IntegralConstantExpression)
5313 PreferredTypeIsPointer);
5323 Results.getCompletionContext(), Results.data(),
5329 bool IsParenthesized,
5330 bool IsAddressOfOperand) {
5333 IsAddressOfOperand);
5358 if (Protocol->hasDefinition())
5359 return Protocol->getDefinition();
5373 Builder.AddResultTypeChunk(
5375 Policy, Builder.getAllocator()));
5381 Builder.AddPlaceholderChunk(
"...");
5383 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
5388 std::string PlaceholderStr =
5391 if (I == N - 1 && BlockProtoLoc &&
5393 PlaceholderStr +=
", ...";
5396 Builder.AddPlaceholderChunk(
5397 Builder.getAllocator().CopyString(PlaceholderStr));
5407 bool AllowNullaryMethods,
DeclContext *CurContext,
5409 bool IsBaseExprStatement =
false,
5410 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
5418 if (!AddedProperties.insert(P->getIdentifier()).second)
5423 if (!P->getType().getTypePtr()->isBlockPointerType() ||
5424 !IsBaseExprStatement) {
5426 Result(P, Results.getBasePriority(P), std::nullopt);
5427 if (!InOriginalClass)
5429 Results.MaybeAddResult(R, CurContext);
5441 Result(P, Results.getBasePriority(P), std::nullopt);
5442 if (!InOriginalClass)
5444 Results.MaybeAddResult(R, CurContext);
5451 Results.getCodeCompletionTUInfo());
5454 BlockLoc, BlockProtoLoc);
5455 Result R =
Result(Builder.TakeString(), P, Results.getBasePriority(P));
5456 if (!InOriginalClass)
5458 Results.MaybeAddResult(R, CurContext);
5462 if (!P->isReadOnly()) {
5464 Results.getCodeCompletionTUInfo());
5468 Builder.AddTypedTextChunk(
5469 Results.getAllocator().CopyString(P->getName()));
5474 BlockProtoLoc,
true);
5476 Builder.AddPlaceholderChunk(
5477 Builder.getAllocator().CopyString(PlaceholderStr));
5485 Result(Builder.TakeString(), P,
5486 Results.getBasePriority(P) +
5490 if (!InOriginalClass)
5492 Results.MaybeAddResult(R, CurContext);
5496 if (IsClassProperty) {
5505 if (AllowNullaryMethods) {
5510 const IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
5513 if (!AddedProperties.insert(Name).second)
5516 Results.getCodeCompletionTUInfo());
5518 Builder.AddTypedTextChunk(
5519 Results.getAllocator().CopyString(Name->
getName()));
5522 if (!InOriginalClass)
5524 Results.MaybeAddResult(R, CurContext);
5527 if (IsClassProperty) {
5528 for (
const auto *M : Container->
methods()) {
5532 if (!M->getSelector().isUnarySelector() ||
5533 M->getReturnType()->isVoidType() || M->isInstanceMethod())
5538 for (
auto *M : Container->
methods()) {
5539 if (M->getSelector().isUnarySelector())
5547 for (
auto *P : Protocol->protocols())
5549 CurContext, AddedProperties, Results,
5550 IsBaseExprStatement, IsClassProperty,
5553 dyn_cast<ObjCInterfaceDecl>(Container)) {
5554 if (AllowCategories) {
5556 for (
auto *Cat : IFace->known_categories())
5558 CurContext, AddedProperties, Results,
5559 IsBaseExprStatement, IsClassProperty,
5564 for (
auto *I : IFace->all_referenced_protocols())
5566 CurContext, AddedProperties, Results,
5567 IsBaseExprStatement, IsClassProperty,
5571 if (IFace->getSuperClass())
5573 AllowNullaryMethods, CurContext, AddedProperties,
5574 Results, IsBaseExprStatement, IsClassProperty,
5576 }
else if (
const auto *Category =
5577 dyn_cast<ObjCCategoryDecl>(Container)) {
5579 for (
auto *P : Category->protocols())
5581 CurContext, AddedProperties, Results,
5582 IsBaseExprStatement, IsClassProperty,
5591 std::optional<FixItHint> AccessOpFixIt) {
5594 Results.setObjectTypeQualifiers(BaseType.getQualifiers(), BaseKind);
5597 Results.allowNestedNameSpecifiers();
5598 std::vector<FixItHint> FixIts;
5600 FixIts.emplace_back(*AccessOpFixIt);
5601 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
5609 if (!Results.empty()) {
5613 bool IsDependent = BaseType->isDependentType();
5615 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
5633 BaseType = Resolver.
simplifyType(BaseType,
nullptr,
false);
5634 return dyn_cast_if_present<RecordDecl>(
5670 const IdentifierInfo *Name =
nullptr;
5675 std::optional<SmallVector<QualType, 1>> ArgTypes;
5677 enum AccessOperator {
5683 const TypeConstraint *ResultType =
nullptr;
5689 CodeCompletionString *render(Sema &S, CodeCompletionAllocator &Alloc,
5690 CodeCompletionTUInfo &Info)
const {
5691 CodeCompletionBuilder B(Alloc, Info);
5694 std::string AsString;
5696 llvm::raw_string_ostream
OS(AsString);
5697 QualType ExactType = deduceType(*ResultType);
5703 B.AddResultTypeChunk(
Alloc.CopyString(AsString));
5706 B.AddTypedTextChunk(
Alloc.CopyString(Name->
getName()));
5711 for (QualType Arg : *ArgTypes) {
5718 B.AddPlaceholderChunk(
Alloc.CopyString(
5723 return B.TakeString();
5730 ConceptInfo(
const TemplateTypeParmType &BaseType, Scope *S) {
5731 auto *TemplatedEntity = getTemplatedEntity(BaseType.getDecl(), S);
5732 for (
const AssociatedConstraint &AC :
5733 constraintsForTemplatedEntity(TemplatedEntity))
5734 believe(AC.ConstraintExpr, &BaseType);
5737 std::vector<Member> members() {
5738 std::vector<Member> Results;
5739 for (
const auto &E : this->Results)
5740 Results.push_back(E.second);
5741 llvm::sort(Results, [](
const Member &L,
const Member &R) {
5742 return L.Name->getName() <
R.Name->getName();
5749 void believe(
const Expr *E,
const TemplateTypeParmType *
T) {
5752 if (
auto *CSE = dyn_cast<ConceptSpecializationExpr>(E)) {
5763 ConceptDecl *CD = CSE->getConceptDecl();
5766 for (
const auto &Arg : CSE->getTemplateArguments()) {
5767 if (Index >= Params->
size())
5769 if (isApprox(Arg,
T)) {
5770 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Params->
getParam(Index));
5782 }
else if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
5785 if (BO->getOpcode() == BO_LAnd || BO->getOpcode() == BO_LOr) {
5786 believe(BO->getLHS(),
T);
5787 believe(BO->getRHS(),
T);
5789 }
else if (
auto *RE = dyn_cast<RequiresExpr>(E)) {
5791 for (
const concepts::Requirement *Req : RE->getRequirements()) {
5792 if (!Req->isDependent())
5796 if (
auto *TR = dyn_cast<concepts::TypeRequirement>(Req)) {
5798 QualType AssertedType = TR->getType()->getType();
5799 ValidVisitor(
this,
T).TraverseType(AssertedType);
5800 }
else if (
auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
5801 ValidVisitor Visitor(
this,
T);
5805 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
5807 ER->getReturnTypeRequirement().getTypeConstraint();
5808 Visitor.OuterExpr = ER->getExpr();
5810 Visitor.TraverseStmt(ER->getExpr());
5811 }
else if (
auto *NR = dyn_cast<concepts::NestedRequirement>(Req)) {
5812 believe(NR->getConstraintExpr(),
T);
5822 const TemplateTypeParmType *
T;
5824 CallExpr *Caller =
nullptr;
5829 Expr *OuterExpr =
nullptr;
5830 const TypeConstraint *OuterType =
nullptr;
5832 ValidVisitor(ConceptInfo *Outer,
const TemplateTypeParmType *
T)
5833 : Outer(Outer),
T(
T) {
5839 VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E)
override {
5842 if (
Base->isPointerType() && IsArrow) {
5844 Base =
Base->getPointeeType().getTypePtr();
5846 if (isApprox(Base,
T))
5847 addValue(E, E->
getMember(), IsArrow ? Member::Arrow : Member::Dot);
5852 bool VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E)
override {
5854 if (
Qualifier.getKind() == NestedNameSpecifier::Kind::Type &&
5861 bool VisitDependentNameType(DependentNameType *DNT)
override {
5862 NestedNameSpecifier Q = DNT->getQualifier();
5863 if (Q.
getKind() == NestedNameSpecifier::Kind::Type &&
5865 addType(DNT->getIdentifier());
5874 if (NNS.
getKind() == NestedNameSpecifier::Kind::Type) {
5876 if (NestedNameSpecifier Q = NNST->
getPrefix();
5877 Q.
getKind() == NestedNameSpecifier::Kind::Type &&
5879 if (
const auto *DNT = dyn_cast_or_null<DependentNameType>(NNST))
5880 addType(DNT->getIdentifier());
5891 bool VisitCallExpr(CallExpr *CE)
override {
5898 void addResult(
Member &&M) {
5899 auto R = Outer->Results.try_emplace(M.Name);
5904 std::make_tuple(M.ArgTypes.has_value(), M.ResultType !=
nullptr,
5905 M.Operator) > std::make_tuple(O.ArgTypes.has_value(),
5906 O.ResultType !=
nullptr,
5911 void addType(
const IdentifierInfo *Name) {
5916 M.Operator = Member::Colons;
5917 addResult(std::move(M));
5920 void addValue(Expr *E, DeclarationName Name,
5921 Member::AccessOperator Operator) {
5926 Result.Operator = Operator;
5929 if (Caller !=
nullptr && Callee == E) {
5930 Result.ArgTypes.emplace();
5931 for (
const auto *Arg : Caller->
arguments())
5932 Result.ArgTypes->push_back(Arg->getType());
5933 if (Caller == OuterExpr) {
5934 Result.ResultType = OuterType;
5938 Result.ResultType = OuterType;
5940 addResult(std::move(
Result));
5944 static bool isApprox(
const TemplateArgument &Arg,
const Type *
T) {
5949 static bool isApprox(
const Type *T1,
const Type *T2) {
5958 static DeclContext *getTemplatedEntity(
const TemplateTypeParmDecl *D,
5962 Scope *Inner =
nullptr;
5965 return Inner ? Inner->
getEntity() :
nullptr;
5974 static SmallVector<AssociatedConstraint, 1>
5975 constraintsForTemplatedEntity(DeclContext *DC) {
5976 SmallVector<AssociatedConstraint, 1>
Result;
5981 TD->getAssociatedConstraints(
Result);
5983 if (
const auto *CTPSD =
5984 dyn_cast<ClassTemplatePartialSpecializationDecl>(DC))
5985 CTPSD->getAssociatedConstraints(
Result);
5986 if (
const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl>(DC))
5987 VTPSD->getAssociatedConstraints(
Result);
5993 static QualType deduceType(
const TypeConstraint &
T) {
5996 DeclarationName DN =
5997 T.getConceptReference()->getConceptNameInfo().getName();
5999 if (
const auto *Args =
T.getTemplateArgsAsWritten())
6000 if (Args->getNumTemplateArgs() == 1) {
6001 const auto &Arg = Args->arguments().front().getArgument();
6008 llvm::DenseMap<const IdentifierInfo *, Member> Results;
6015QualType getApproximateType(
const Expr *E, HeuristicResolver &Resolver) {
6029Expr *unwrapParenList(Expr *Base) {
6030 if (
auto *PLE = llvm::dyn_cast_or_null<ParenListExpr>(Base)) {
6031 if (PLE->getNumExprs() == 0)
6033 Base = PLE->getExpr(PLE->getNumExprs() - 1);
6042 bool IsBaseExprStatement,
QualType PreferredType) {
6044 OtherOpBase = unwrapParenList(OtherOpBase);
6049 SemaRef.PerformMemberExprBaseConversion(
Base, IsArrow);
6053 getApproximateType(ConvertedBase.
get(),
Resolver);
6059 !PointeeType.isNull()) {
6060 ConvertedBaseType = PointeeType;
6079 &ResultBuilder::IsMember);
6081 auto DoCompletion = [&](
Expr *
Base,
bool IsArrow,
6082 std::optional<FixItHint> AccessOpFixIt) ->
bool {
6087 SemaRef.PerformMemberExprBaseConversion(
Base, IsArrow);
6093 if (BaseType.isNull())
6099 !PointeeType.isNull()) {
6100 BaseType = PointeeType;
6102 }
else if (BaseType->isObjCObjectPointerType() ||
6103 BaseType->isTemplateTypeParmType()) {
6112 RD, std::move(AccessOpFixIt));
6113 }
else if (
const auto *TTPT =
6114 dyn_cast<TemplateTypeParmType>(BaseType.getTypePtr())) {
6116 IsArrow ? ConceptInfo::Member::Arrow : ConceptInfo::Member::Dot;
6117 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
6118 if (R.Operator != Operator)
6124 Result.FixIts.push_back(*AccessOpFixIt);
6125 Results.AddResult(std::move(
Result));
6127 }
else if (!IsArrow && BaseType->isObjCObjectPointerType()) {
6131 if (AccessOpFixIt) {
6139 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
6142 AddedProperties, Results, IsBaseExprStatement);
6148 SemaRef.CurContext, AddedProperties, Results,
6149 IsBaseExprStatement,
false,
6151 }
else if ((IsArrow && BaseType->isObjCObjectPointerType()) ||
6152 (!IsArrow && BaseType->isObjCObjectType())) {
6156 if (AccessOpFixIt) {
6162 Class = ObjCPtr->getInterfaceDecl();
6168 CodeCompletionDeclConsumer Consumer(Results,
Class, BaseType);
6169 Results.setFilter(&ResultBuilder::IsObjCIvar);
6181 Results.EnterNewScope();
6183 bool CompletionSucceded = DoCompletion(
Base, IsArrow, std::nullopt);
6187 CompletionSucceded |= DoCompletion(
6188 OtherOpBase, !IsArrow,
6192 Results.ExitScope();
6194 if (!CompletionSucceded)
6199 Results.getCompletionContext(), Results.data(),
6205 bool IsBaseExprStatement) {
6208 SemaRef.ObjC().getObjCInterfaceDecl(ClassNamePtr, ClassNameLoc);
6215 &ResultBuilder::IsMember);
6216 Results.EnterNewScope();
6220 AddedProperties, Results, IsBaseExprStatement,
6222 Results.ExitScope();
6224 Results.getCompletionContext(), Results.data(),
6232 ResultBuilder::LookupFilter Filter =
nullptr;
6237 Filter = &ResultBuilder::IsEnum;
6242 Filter = &ResultBuilder::IsUnion;
6249 Filter = &ResultBuilder::IsClassOrStruct;
6254 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
6259 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
6262 Results.setFilter(Filter);
6269 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
6276 Results.getCompletionContext(), Results.data(),
6283 Results.AddResult(
"const");
6285 Results.AddResult(
"volatile");
6287 Results.AddResult(
"restrict");
6289 Results.AddResult(
"_Atomic");
6291 Results.AddResult(
"__unaligned");
6298 Results.EnterNewScope();
6300 Results.ExitScope();
6302 Results.getCompletionContext(), Results.data(),
6311 Results.EnterNewScope();
6314 Results.AddResult(
"noexcept");
6318 Results.AddResult(
"final");
6320 Results.AddResult(
"override");
6323 Results.ExitScope();
6325 Results.getCompletionContext(), Results.data(),
6338 SemaRef.getCurFunction()->SwitchStack.back().getPointer();
6346 Data.IntegralConstantExpression =
true;
6355 CoveredEnumerators Enumerators;
6357 SC = SC->getNextSwitchCase()) {
6358 CaseStmt *Case = dyn_cast<CaseStmt>(SC);
6363 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
6365 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
6385 Enumerators.SuggestedQualifier = DRE->getQualifier();
6400 Results.getCompletionContext(), Results.data(),
6405 if (Args.size() && !Args.data())
6408 for (
unsigned I = 0; I != Args.size(); ++I)
6429 if (Candidate.Function) {
6430 if (Candidate.Function->isDeleted())
6433 Candidate.Function) &&
6434 Candidate.Function->getNumParams() <= ArgSize &&
6443 if (Candidate.Viable)
6457 for (
auto &Candidate : Candidates) {
6458 QualType CandidateParamType = Candidate.getParamType(N);
6459 if (CandidateParamType.
isNull())
6461 if (ParamType.
isNull()) {
6462 ParamType = CandidateParamType;
6479 if (Candidates.empty())
6483 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc,
6491 Fn = unwrapParenList(Fn);
6502 auto ArgsWithoutDependentTypes =
6507 Expr *NakedFn = Fn->IgnoreParenCasts();
6513 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
6514 SemaRef.AddOverloadedCallCandidates(ULE, ArgsWithoutDependentTypes,
6517 }
else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
6519 if (UME->hasExplicitTemplateArgs()) {
6520 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
6521 TemplateArgs = &TemplateArgsBuffer;
6526 1, UME->isImplicitAccess() ?
nullptr : UME->getBase());
6527 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6528 ArgsWithoutDependentTypes.end());
6530 Decls.
append(UME->decls_begin(), UME->decls_end());
6531 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
6532 SemaRef.AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
6535 FirstArgumentIsBase);
6538 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
6539 FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl());
6540 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
6541 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
6547 SemaRef.AddOverloadCandidate(FD,
6549 ArgsWithoutDependentTypes, CandidateSet,
6559 getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
6561 SemaRef.LookupQualifiedName(R, DC);
6562 R.suppressDiagnostics();
6564 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6565 ArgsWithoutDependentTypes.end());
6566 SemaRef.AddFunctionCandidates(R.asUnresolvedSet(), ArgExprs,
6579 if (!
T->getPointeeType().isNull())
6580 T =
T->getPointeeType();
6583 if (!
SemaRef.TooManyArguments(FP->getNumParams(),
6584 ArgsWithoutDependentTypes.size(),
6620static std::optional<unsigned>
6623 static constexpr unsigned Invalid = std::numeric_limits<unsigned>::max();
6629 unsigned ArgsAfterDesignator = 0;
6630 for (
const Expr *Arg : Args) {
6631 if (
const auto *DIE = dyn_cast<DesignatedInitExpr>(Arg)) {
6632 if (DIE->size() == 1 && DIE->getDesignator(0)->isFieldDesignator()) {
6633 DesignatedFieldName = DIE->getDesignator(0)->getFieldName();
6634 ArgsAfterDesignator = 0;
6641 ++ArgsAfterDesignator;
6644 if (!DesignatedFieldName)
6645 return std::nullopt;
6649 unsigned DesignatedIndex = 0;
6650 const FieldDecl *DesignatedField =
nullptr;
6651 for (
const auto *Field :
Aggregate.getAggregate()->fields()) {
6652 if (Field->getIdentifier() == DesignatedFieldName) {
6653 DesignatedField = Field;
6658 if (!DesignatedField)
6662 unsigned AggregateSize =
Aggregate.getNumParams();
6663 while (DesignatedIndex < AggregateSize &&
6664 Aggregate.getParamDecl(DesignatedIndex) != DesignatedField)
6668 return DesignatedIndex + ArgsAfterDesignator + 1;
6691 if (Braced && !RD->
isUnion() &&
6696 if (
auto NextIndex =
6699 if (*NextIndex >= AggregateSize)
6701 Results.push_back(AggregateSig);
6707 if (Args.size() < AggregateSize)
6708 Results.push_back(AggregateSig);
6718 if (
auto *FD = dyn_cast<FunctionDecl>(
C)) {
6722 SemaRef.isInitListConstructor(FD))
6729 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
6731 SemaRef.isInitListConstructor(FTD->getTemplatedDecl()))
6734 SemaRef.AddTemplateOverloadCandidate(
6736 nullptr, Args, CandidateSet,
6757 dyn_cast<CXXConstructorDecl>(ConstructorDecl);
6762 Constructor->getParent(), SS, TemplateTypeTy, II))
6764 MemberDecl->getLocation(), ArgExprs,
6765 OpenParLoc, Braced);
6773 if (Index < Params.
size())
6776 Param = Params.
asArray().back();
6782 return llvm::isa<TemplateTypeParmDecl>(Param);
6784 return llvm::isa<NonTypeTemplateParmDecl>(Param);
6786 return llvm::isa<TemplateTemplateParmDecl>(Param);
6788 llvm_unreachable(
"Unhandled switch case");
6800 bool Matches =
true;
6801 for (
unsigned I = 0; I < Args.size(); ++I) {
6808 Results.emplace_back(TD);
6812 if (
const auto *TD =
Template.getAsTemplateDecl()) {
6814 }
else if (
const auto *OTS =
Template.getAsOverloadedTemplate()) {
6816 if (
const auto *TD = llvm::dyn_cast<TemplateDecl>(ND))
6827 if (
const auto *FD = llvm::dyn_cast<FieldDecl>(
Member))
6829 if (
const auto *IFD = llvm::dyn_cast<IndirectFieldDecl>(
Member))
6830 return IFD->getAnonField();
6841 if (BaseType.isNull())
6845 if (D.isArrayDesignator() || D.isArrayRangeDesignator()) {
6846 if (BaseType->isDependentType()) {
6847 BaseType = Context.DependentTy;
6850 const ArrayType *AT = Context.getAsArrayType(BaseType);
6857 assert(D.isFieldDesignator());
6858 if (BaseType->isDependentType()) {
6859 BaseType = Context.DependentTy;
6867 const FieldDecl *MemberDecl = LookupField(RD, D);
6880 if (BaseType.isNull())
6883 if (!RD || RD->fields().empty())
6891 Results.EnterNewScope();
6892 for (
const Decl *D : RD->decls()) {
6894 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(D))
6895 FD = IFD->getAnonField();
6896 else if (
auto *DFD = dyn_cast<FieldDecl>(D))
6903 ResultBuilder::Result
Result(FD, Results.getBasePriority(FD));
6906 Results.ExitScope();
6908 Results.getCompletionContext(), Results.data(),
6920 SemaRef.LookupQualifiedName(R, RD);
6925 if (
auto *FD = dyn_cast<FieldDecl>(ND))
6927 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(ND))
6928 return IFD->getAnonField();
6934 if (BaseType.isNull())
6945 &ResultBuilder::IsOffsetofField);
6947 Results.EnterNewScope();
6948 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType);
6956 Results.ExitScope();
6959 Results.getCompletionContext(), Results.data(),
6964 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
6973 Data.IgnoreDecls.push_back(VD);
6983 Results.getCodeCompletionTUInfo());
6985 if (!AfterExclaim) {
6986 if (Results.includeCodePatterns()) {
6987 Builder.AddTypedTextChunk(
"constexpr");
6990 Builder.AddPlaceholderChunk(
"condition");
6995 Builder.AddPlaceholderChunk(
"statements");
6998 Results.AddResult({Builder.TakeString()});
7000 Results.AddResult({
"constexpr"});
7005 if (Results.includeCodePatterns()) {
7006 Builder.AddTypedTextChunk(
"consteval");
7010 Builder.AddPlaceholderChunk(
"statements");
7013 Results.AddResult({Builder.TakeString()});
7015 Results.AddResult({
"consteval"});
7020 Results.getCompletionContext(), Results.data(),
7028 Results.setFilter(&ResultBuilder::IsOrdinaryName);
7029 Results.EnterNewScope();
7031 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7040 Results.getCodeCompletionTUInfo());
7042 auto AddElseBodyPattern = [&] {
7047 Builder.AddPlaceholderChunk(
"statements");
7053 Builder.AddPlaceholderChunk(
"statement");
7057 Builder.AddTypedTextChunk(
"else");
7058 if (Results.includeCodePatterns())
7059 AddElseBodyPattern();
7060 Results.AddResult(Builder.TakeString());
7063 Builder.AddTypedTextChunk(
"else if");
7067 Builder.AddPlaceholderChunk(
"condition");
7069 Builder.AddPlaceholderChunk(
"expression");
7071 if (Results.includeCodePatterns()) {
7072 AddElseBodyPattern();
7074 Results.AddResult(Builder.TakeString());
7076 Results.ExitScope();
7085 Results.getCompletionContext(), Results.data(),
7091 bool IsAddressOfOperand,
bool IsInDeclarationContext,
QualType BaseType,
7110 if (!PreferredType.
isNull())
7111 DummyResults.setPreferredType(PreferredType);
7113 CodeCompletionDeclConsumer Consumer(DummyResults, S->
getEntity(),
7120 DummyResults.getCompletionContext(),
nullptr, 0);
7127 std::optional<Sema::ContextRAII> SimulateContext;
7130 if (IsInDeclarationContext && Ctx !=
nullptr)
7131 SimulateContext.emplace(
SemaRef, Ctx);
7137 if (Ctx ==
nullptr ||
SemaRef.RequireCompleteDeclContext(SS, Ctx))
7143 if (!PreferredType.
isNull())
7144 Results.setPreferredType(PreferredType);
7145 Results.EnterNewScope();
7151 Results.AddResult(
"template");
7156 if (
const auto *TTPT = dyn_cast<TemplateTypeParmType>(NNS.
getAsType())) {
7157 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
7158 if (R.Operator != ConceptInfo::Member::Colons)
7172 if (Ctx && !EnteringContext)
7174 Results.ExitScope();
7178 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
7179 Consumer.setIsInDeclarationContext(IsInDeclarationContext);
7180 Consumer.setIsAddressOfOperand(IsAddressOfOperand);
7186 SimulateContext.reset();
7188 Results.getCompletionContext(), Results.data(),
7199 Context.setIsUsingDeclaration(
true);
7203 &ResultBuilder::IsNestedNameSpecifier);
7204 Results.EnterNewScope();
7212 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7216 Results.ExitScope();
7219 Results.getCompletionContext(), Results.data(),
7232 &ResultBuilder::IsNamespaceOrAlias);
7233 Results.EnterNewScope();
7234 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7238 Results.ExitScope();
7240 Results.getCompletionContext(), Results.data(),
7252 bool SuppressedGlobalResults =
7257 SuppressedGlobalResults
7260 &ResultBuilder::IsNamespace);
7262 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
7267 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
7272 OrigToLatest[NS->getFirstDecl()] = *NS;
7276 Results.EnterNewScope();
7277 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
7278 NS = OrigToLatest.begin(),
7279 NSEnd = OrigToLatest.end();
7284 SemaRef.CurContext,
nullptr,
false);
7285 Results.ExitScope();
7289 Results.getCompletionContext(), Results.data(),
7301 &ResultBuilder::IsNamespaceOrAlias);
7302 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7307 Results.getCompletionContext(), Results.data(),
7319 &ResultBuilder::IsType);
7320 Results.EnterNewScope();
7324#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
7325 if (OO_##Name != OO_Conditional) \
7326 Results.AddResult(Result(Spelling));
7327#include "clang/Basic/OperatorKinds.def"
7330 Results.allowNestedNameSpecifiers();
7331 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7338 Results.ExitScope();
7341 Results.getCompletionContext(), Results.data(),
7350 SemaRef.AdjustDeclIfTemplate(ConstructorD);
7352 auto *
Constructor = dyn_cast<CXXConstructorDecl>(ConstructorD);
7359 Results.EnterNewScope();
7364 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
7365 if (Initializers[I]->isBaseInitializer())
7367 QualType(Initializers[I]->getBaseClass(), 0)));
7369 InitializedFields.insert(
7375 bool SawLastInitializer = Initializers.empty();
7378 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
7380 Results.getCodeCompletionTUInfo());
7381 Builder.AddTypedTextChunk(Name);
7383 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND))
7385 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
7387 FunTemplDecl->getTemplatedDecl(), Builder);
7389 return Builder.TakeString();
7391 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
7394 Results.getCodeCompletionTUInfo());
7395 Builder.AddTypedTextChunk(Name);
7397 Builder.AddPlaceholderChunk(
Type);
7401 Builder.TakeString(), ND,
7405 return Results.AddResult(CCR);
7408 Builder.TakeString(),
7411 auto AddCtorsWithName = [&](
const CXXRecordDecl *RD,
unsigned int Priority,
7412 const char *Name,
const FieldDecl *FD) {
7414 return AddDefaultCtorInit(Name,
7415 FD ? Results.getAllocator().CopyString(
7416 FD->getType().getAsString(Policy))
7420 if (Ctors.begin() == Ctors.end())
7421 return AddDefaultCtorInit(Name, Name, RD);
7425 Results.AddResult(CCR);
7429 const char *BaseName =
7430 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
7431 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
7436 auto AddField = [&](
const FieldDecl *FD) {
7437 const char *FieldName =
7438 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
7439 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
7445 for (
const auto &
Base : ClassDecl->
bases()) {
7446 if (!InitializedBases
7449 SawLastInitializer =
7450 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7452 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7457 SawLastInitializer =
false;
7461 for (
const auto &
Base : ClassDecl->
vbases()) {
7462 if (!InitializedBases
7465 SawLastInitializer =
7466 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7468 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7473 SawLastInitializer =
false;
7477 for (
auto *Field : ClassDecl->
fields()) {
7478 if (!InitializedFields.insert(
cast<FieldDecl>(Field->getCanonicalDecl()))
7480 SawLastInitializer = !Initializers.empty() &&
7481 Initializers.back()->isAnyMemberInitializer() &&
7482 Initializers.back()->getAnyMember() == Field;
7486 if (!Field->getDeclName())
7490 SawLastInitializer =
false;
7492 Results.ExitScope();
7495 Results.getCompletionContext(), Results.data(),
7510 bool AfterAmpersand) {
7514 Results.EnterNewScope();
7518 bool IncludedThis =
false;
7521 IncludedThis =
true;
7530 for (
const auto *D : S->
decls()) {
7531 const auto *Var = dyn_cast<VarDecl>(D);
7532 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
7535 if (
Known.insert(Var->getIdentifier()).second)
7537 SemaRef.CurContext,
nullptr,
false);
7545 Results.ExitScope();
7548 Results.getCompletionContext(), Results.data(),
7558 auto ShouldAddDefault = [&D,
this]() {
7570 auto Op = Id.OperatorFunctionId.Operator;
7573 if (Op == OverloadedOperatorKind::OO_Equal)
7576 (Op == OverloadedOperatorKind::OO_EqualEqual ||
7577 Op == OverloadedOperatorKind::OO_ExclaimEqual ||
7578 Op == OverloadedOperatorKind::OO_Less ||
7579 Op == OverloadedOperatorKind::OO_LessEqual ||
7580 Op == OverloadedOperatorKind::OO_Greater ||
7581 Op == OverloadedOperatorKind::OO_GreaterEqual ||
7582 Op == OverloadedOperatorKind::OO_Spaceship))
7588 Results.EnterNewScope();
7589 if (ShouldAddDefault())
7590 Results.AddResult(
"default");
7593 Results.AddResult(
"delete");
7594 Results.ExitScope();
7596 Results.getCompletionContext(), Results.data(),
7602#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
7605 ResultBuilder &Results,
bool NeedAt) {
7611 Results.getCodeCompletionTUInfo());
7612 if (LangOpts.ObjC) {
7616 Builder.AddPlaceholderChunk(
"property");
7617 Results.AddResult(
Result(Builder.TakeString()));
7622 Builder.AddPlaceholderChunk(
"property");
7623 Results.AddResult(
Result(Builder.TakeString()));
7628 ResultBuilder &Results,
bool NeedAt) {
7634 if (LangOpts.ObjC) {
7649 Results.getCodeCompletionTUInfo());
7654 Builder.AddPlaceholderChunk(
"name");
7655 Results.AddResult(
Result(Builder.TakeString()));
7657 if (Results.includeCodePatterns()) {
7663 Builder.AddPlaceholderChunk(
"class");
7664 Results.AddResult(
Result(Builder.TakeString()));
7669 Builder.AddPlaceholderChunk(
"protocol");
7670 Results.AddResult(
Result(Builder.TakeString()));
7675 Builder.AddPlaceholderChunk(
"class");
7676 Results.AddResult(
Result(Builder.TakeString()));
7680 Builder.AddTypedTextChunk(
7683 Builder.AddPlaceholderChunk(
"alias");
7685 Builder.AddPlaceholderChunk(
"class");
7686 Results.AddResult(
Result(Builder.TakeString()));
7688 if (Results.getSema().getLangOpts().Modules) {
7692 Builder.AddPlaceholderChunk(
"module");
7693 Results.AddResult(
Result(Builder.TakeString()));
7701 Results.EnterNewScope();
7704 else if (
SemaRef.CurContext->isObjCContainer())
7708 Results.ExitScope();
7710 Results.getCompletionContext(), Results.data(),
7717 Results.getCodeCompletionTUInfo());
7720 const char *EncodeType =
"char[]";
7721 if (Results.getSema().getLangOpts().CPlusPlus ||
7722 Results.getSema().getLangOpts().ConstStrings)
7723 EncodeType =
"const char[]";
7724 Builder.AddResultTypeChunk(EncodeType);
7727 Builder.AddPlaceholderChunk(
"type-name");
7729 Results.AddResult(
Result(Builder.TakeString()));
7732 Builder.AddResultTypeChunk(
"Protocol *");
7735 Builder.AddPlaceholderChunk(
"protocol-name");
7737 Results.AddResult(
Result(Builder.TakeString()));
7740 Builder.AddResultTypeChunk(
"SEL");
7743 Builder.AddPlaceholderChunk(
"selector");
7745 Results.AddResult(
Result(Builder.TakeString()));
7748 Builder.AddResultTypeChunk(
"NSString *");
7750 Builder.AddPlaceholderChunk(
"string");
7751 Builder.AddTextChunk(
"\"");
7752 Results.AddResult(
Result(Builder.TakeString()));
7755 Builder.AddResultTypeChunk(
"NSArray *");
7757 Builder.AddPlaceholderChunk(
"objects, ...");
7759 Results.AddResult(
Result(Builder.TakeString()));
7762 Builder.AddResultTypeChunk(
"NSDictionary *");
7764 Builder.AddPlaceholderChunk(
"key");
7767 Builder.AddPlaceholderChunk(
"object, ...");
7769 Results.AddResult(
Result(Builder.TakeString()));
7772 Builder.AddResultTypeChunk(
"id");
7774 Builder.AddPlaceholderChunk(
"expression");
7776 Results.AddResult(
Result(Builder.TakeString()));
7782 Results.getCodeCompletionTUInfo());
7784 if (Results.includeCodePatterns()) {
7789 Builder.AddPlaceholderChunk(
"statements");
7791 Builder.AddTextChunk(
"@catch");
7793 Builder.AddPlaceholderChunk(
"parameter");
7796 Builder.AddPlaceholderChunk(
"statements");
7798 Builder.AddTextChunk(
"@finally");
7800 Builder.AddPlaceholderChunk(
"statements");
7802 Results.AddResult(
Result(Builder.TakeString()));
7808 Builder.AddPlaceholderChunk(
"expression");
7809 Results.AddResult(
Result(Builder.TakeString()));
7811 if (Results.includeCodePatterns()) {
7816 Builder.AddPlaceholderChunk(
"expression");
7819 Builder.AddPlaceholderChunk(
"statements");
7821 Results.AddResult(
Result(Builder.TakeString()));
7826 ResultBuilder &Results,
bool NeedAt) {
7839 Results.EnterNewScope();
7841 Results.ExitScope();
7843 Results.getCompletionContext(), Results.data(),
7851 Results.EnterNewScope();
7854 Results.ExitScope();
7856 Results.getCompletionContext(), Results.data(),
7864 Results.EnterNewScope();
7866 Results.ExitScope();
7868 Results.getCompletionContext(), Results.data(),
7876 if (Attributes & NewFlag)
7879 Attributes |= NewFlag;
7887 unsigned AssignCopyRetMask =
7893 if (AssignCopyRetMask &&
7915 Results.EnterNewScope();
7952 Results.getCodeCompletionTUInfo());
7961 Results.getCodeCompletionTUInfo());
7974 Results.ExitScope();
7976 Results.getCompletionContext(), Results.data(),
7990 bool AllowSameLength =
true) {
7991 unsigned NumSelIdents = SelIdents.size();
8004 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
8007 for (
unsigned I = 0; I != NumSelIdents; ++I)
8017 bool AllowSameLength =
true) {
8051 ResultBuilder &Results,
bool InOriginalClass =
true,
8052 bool IsRootClass =
false) {
8056 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
8060 if (M->isInstanceMethod() == WantInstanceMethods ||
8061 (IsRootClass && !WantInstanceMethods)) {
8067 if (!Selectors.insert(M->getSelector()).second)
8071 Result(M, Results.getBasePriority(M), std::nullopt);
8072 R.StartParameter = SelIdents.size();
8073 R.AllParametersAreInformative = (WantKind !=
MK_Any);
8074 if (!InOriginalClass)
8076 Results.MaybeAddResult(R, CurContext);
8081 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
8082 if (Protocol->hasDefinition()) {
8084 Protocol->getReferencedProtocols();
8086 E = Protocols.
end();
8088 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
8089 Selectors, AllowSameLength, Results,
false, IsRootClass);
8098 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
8099 Selectors, AllowSameLength, Results,
false, IsRootClass);
8103 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
8104 CurContext, Selectors, AllowSameLength, Results,
8105 InOriginalClass, IsRootClass);
8109 CatDecl->getReferencedProtocols();
8111 E = Protocols.
end();
8113 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
8114 Selectors, AllowSameLength, Results,
false, IsRootClass);
8118 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
8119 Selectors, AllowSameLength, Results, InOriginalClass,
8127 SelIdents, CurContext, Selectors, AllowSameLength, Results,
8132 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
8133 Selectors, AllowSameLength, Results, InOriginalClass,
8140 dyn_cast_or_null<ObjCInterfaceDecl>(
SemaRef.CurContext);
8143 dyn_cast_or_null<ObjCCategoryDecl>(
SemaRef.CurContext))
8144 Class = Category->getClassInterface();
8154 Results.EnterNewScope();
8160 Results.ExitScope();
8162 Results.getCompletionContext(), Results.data(),
8169 dyn_cast_or_null<ObjCInterfaceDecl>(
SemaRef.CurContext);
8172 dyn_cast_or_null<ObjCCategoryDecl>(
SemaRef.CurContext))
8173 Class = Category->getClassInterface();
8183 Results.EnterNewScope();
8190 Results.ExitScope();
8192 Results.getCompletionContext(), Results.data(),
8201 Results.EnterNewScope();
8204 bool AddedInOut =
false;
8207 Results.AddResult(
"in");
8208 Results.AddResult(
"inout");
8213 Results.AddResult(
"out");
8215 Results.AddResult(
"inout");
8220 Results.AddResult(
"bycopy");
8221 Results.AddResult(
"byref");
8222 Results.AddResult(
"oneway");
8225 Results.AddResult(
"nonnull");
8226 Results.AddResult(
"nullable");
8227 Results.AddResult(
"null_unspecified");
8235 SemaRef.PP.isMacroDefined(
"IBAction")) {
8237 Results.getCodeCompletionTUInfo(),
8239 Builder.AddTypedTextChunk(
"IBAction");
8241 Builder.AddPlaceholderChunk(
"selector");
8244 Builder.AddTextChunk(
"id");
8246 Builder.AddTextChunk(
"sender");
8257 Results.ExitScope();
8260 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
8261 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
8270 Results.getCompletionContext(), Results.data(),
8279 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(E);
8297 switch (Msg->getReceiverKind()) {
8301 IFace = ObjType->getInterface();
8305 QualType T = Msg->getInstanceReceiver()->getType();
8307 IFace = Ptr->getInterfaceDecl();
8320 if (Method->isInstanceMethod())
8321 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
8322 .Case(
"retain", IFace)
8323 .Case(
"strong", IFace)
8324 .Case(
"autorelease", IFace)
8325 .Case(
"copy", IFace)
8326 .Case(
"copyWithZone", IFace)
8327 .Case(
"mutableCopy", IFace)
8328 .Case(
"mutableCopyWithZone", IFace)
8329 .Case(
"awakeFromCoder", IFace)
8330 .Case(
"replacementObjectFromCoder", IFace)
8331 .Case(
"class", IFace)
8332 .Case(
"classForCoder", IFace)
8333 .Case(
"superclass", Super)
8336 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
8338 .Case(
"alloc", IFace)
8339 .Case(
"allocWithZone", IFace)
8340 .Case(
"class", IFace)
8341 .Case(
"superclass", Super)
8361static ObjCMethodDecl *
8364 ResultBuilder &Results) {
8375 while ((Class = Class->getSuperClass()) && !SuperMethod) {
8377 SuperMethod = Class->getMethod(CurMethod->
getSelector(),
8382 for (
const auto *Cat : Class->known_categories()) {
8383 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
8401 CurP != CurPEnd; ++CurP, ++SuperP) {
8404 (*SuperP)->getType()))
8408 if (!(*CurP)->getIdentifier())
8414 Results.getCodeCompletionTUInfo());
8418 Results.getCompletionContext().getBaseType(), Builder);
8421 if (NeedSuperKeyword) {
8422 Builder.AddTypedTextChunk(
"super");
8428 if (NeedSuperKeyword)
8429 Builder.AddTextChunk(
8432 Builder.AddTypedTextChunk(
8436 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
8437 if (I > SelIdents.size())
8440 if (I < SelIdents.size())
8441 Builder.AddInformativeChunk(
8443 else if (NeedSuperKeyword || I > SelIdents.size()) {
8444 Builder.AddTextChunk(
8446 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8447 (*CurP)->getIdentifier()->getName()));
8449 Builder.AddTypedTextChunk(
8451 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8452 (*CurP)->getIdentifier()->getName()));
8464 ResultBuilder Results(
8469 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
8470 : &ResultBuilder::IsObjCMessageReceiver);
8472 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
8473 Results.EnterNewScope();
8482 if (Iface->getSuperClass()) {
8483 Results.AddResult(
Result(
"super"));
8491 Results.ExitScope();
8496 Results.getCompletionContext(), Results.data(),
8506 CDecl = CurMethod->getClassInterface();
8515 if (CurMethod->isInstanceMethod()) {
8520 AtArgumentExpression, CDecl);
8530 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
8532 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
8534 getASTContext().getTypeDeclType(TD)->getAs<ObjCObjectType>())
8535 CDecl = Iface->getInterface();
8545 SemaRef.ActOnIdExpression(S, SS, TemplateKWLoc,
id,
8549 SelIdents, AtArgumentExpression);
8559 AtArgumentExpression,
8566 unsigned NumSelIdents) {
8568 ASTContext &Context = Results.getSema().Context;
8572 Result *ResultsData = Results.data();
8573 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
8574 Result &R = ResultsData[I];
8575 if (R.Kind == Result::RK_Declaration &&
8577 if (R.Priority <= BestPriority) {
8579 if (NumSelIdents <= Method->param_size()) {
8581 Method->parameters()[NumSelIdents - 1]->getType();
8582 if (R.Priority < BestPriority || PreferredType.
isNull()) {
8583 BestPriority = R.Priority;
8584 PreferredType = MyPreferredType;
8585 }
else if (!Context.hasSameUnqualifiedType(PreferredType,
8594 return PreferredType;
8600 bool AtArgumentExpression,
bool IsSuper,
8601 ResultBuilder &Results) {
8616 Results.EnterNewScope();
8623 Results.Ignore(SuperMethod);
8629 Results.setPreferredSelector(CurMethod->getSelector());
8634 Selectors, AtArgumentExpression, Results);
8652 for (SemaObjC::GlobalMethodPool::iterator
8657 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
8661 Result R(MethList->getMethod(),
8662 Results.getBasePriority(MethList->getMethod()),
8664 R.StartParameter = SelIdents.size();
8665 R.AllParametersAreInformative =
false;
8666 Results.MaybeAddResult(R, SemaRef.
CurContext);
8671 Results.ExitScope();
8676 bool AtArgumentExpression,
bool IsSuper) {
8680 ResultBuilder Results(
8687 AtArgumentExpression, IsSuper, Results);
8694 if (AtArgumentExpression) {
8697 if (PreferredType.
isNull())
8705 Results.getCompletionContext(), Results.data(),
8726 RecExpr = Conv.
get();
8730 : Super ? Context.getObjCObjectPointerType(
8731 Context.getObjCInterfaceType(Super))
8732 : Context.getObjCIdType();
8742 AtArgumentExpression, Super);
8745 Context.getObjCObjectPointerType(Context.getObjCInterfaceType(IFace));
8750 RecExpr = Conv.
get();
8751 ReceiverType = RecExpr->
getType();
8756 ResultBuilder Results(
8760 ReceiverType, SelIdents));
8762 Results.EnterNewScope();
8769 Results.Ignore(SuperMethod);
8775 Results.setPreferredSelector(CurMethod->getSelector());
8788 Selectors, AtArgumentExpression, Results);
8795 for (
auto *I : QualID->quals())
8797 AtArgumentExpression, Results);
8804 SemaRef.CurContext, Selectors, AtArgumentExpression,
8808 for (
auto *I : IFacePtr->quals())
8810 AtArgumentExpression, Results);
8820 for (uint32_t I = 0,
8821 N =
SemaRef.ExternalSource->GetNumExternalSelectors();
8827 SemaRef.ObjC().ReadMethodPool(Sel);
8831 for (SemaObjC::GlobalMethodPool::iterator
8832 M =
SemaRef.ObjC().MethodPool.begin(),
8833 MEnd =
SemaRef.ObjC().MethodPool.end();
8836 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
8840 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
8843 Result R(MethList->getMethod(),
8844 Results.getBasePriority(MethList->getMethod()),
8846 R.StartParameter = SelIdents.size();
8847 R.AllParametersAreInformative =
false;
8848 Results.MaybeAddResult(R,
SemaRef.CurContext);
8852 Results.ExitScope();
8859 if (AtArgumentExpression) {
8862 if (PreferredType.
isNull())
8870 Results.getCompletionContext(), Results.data(),
8877 Data.ObjCCollection =
true;
8883 Data.IgnoreDecls.push_back(*I);
8895 for (uint32_t I = 0, N =
SemaRef.ExternalSource->GetNumExternalSelectors();
8901 SemaRef.ObjC().ReadMethodPool(Sel);
8908 Results.EnterNewScope();
8909 for (SemaObjC::GlobalMethodPool::iterator
8910 M =
SemaRef.ObjC().MethodPool.begin(),
8911 MEnd =
SemaRef.ObjC().MethodPool.end();
8919 Results.getCodeCompletionTUInfo());
8921 Builder.AddTypedTextChunk(
8923 Results.AddResult(Builder.TakeString());
8927 std::string Accumulator;
8928 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
8929 if (I == SelIdents.size()) {
8930 if (!Accumulator.empty()) {
8931 Builder.AddInformativeChunk(
8932 Builder.getAllocator().CopyString(Accumulator));
8933 Accumulator.clear();
8940 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
8941 Results.AddResult(Builder.TakeString());
8943 Results.ExitScope();
8946 Results.getCompletionContext(), Results.data(),
8953 bool OnlyForwardDeclarations,
8954 ResultBuilder &Results) {
8957 for (
const auto *D : Ctx->
decls()) {
8959 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
8960 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
8961 Results.AddResult(
Result(Proto, Results.getBasePriority(Proto),
8963 CurContext,
nullptr,
false);
8974 Results.EnterNewScope();
8981 Pair.getIdentifierInfo(), Pair.getLoc()))
8982 Results.Ignore(Protocol);
8986 SemaRef.CurContext,
false, Results);
8988 Results.ExitScope();
8992 Results.getCompletionContext(), Results.data(),
9002 Results.EnterNewScope();
9006 SemaRef.CurContext,
true, Results);
9008 Results.ExitScope();
9012 Results.getCompletionContext(), Results.data(),
9019 bool OnlyForwardDeclarations,
9020 bool OnlyUnimplemented,
9021 ResultBuilder &Results) {
9024 for (
const auto *D : Ctx->
decls()) {
9026 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
9027 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
9028 (!OnlyUnimplemented || !Class->getImplementation()))
9029 Results.AddResult(
Result(Class, Results.getBasePriority(Class),
9031 CurContext,
nullptr,
false);
9039 Results.EnterNewScope();
9044 SemaRef.CurContext,
false,
false, Results);
9047 Results.ExitScope();
9050 Results.getCompletionContext(), Results.data(),
9058 Results.EnterNewScope();
9063 SemaRef.CurContext,
false,
false, Results);
9066 Results.ExitScope();
9069 Results.getCompletionContext(), Results.data(),
9078 Results.EnterNewScope();
9084 Results.Ignore(CurClass);
9089 SemaRef.CurContext,
false,
false, Results);
9092 Results.ExitScope();
9095 Results.getCompletionContext(), Results.data(),
9103 Results.EnterNewScope();
9108 SemaRef.CurContext,
false,
true, Results);
9111 Results.ExitScope();
9114 Results.getCompletionContext(), Results.data(),
9132 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
9133 for (
const auto *Cat :
Class->visible_categories())
9134 CategoryNames.insert(Cat->getIdentifier());
9138 Results.EnterNewScope();
9140 for (
const auto *D : TU->
decls())
9141 if (
const auto *Category = dyn_cast<ObjCCategoryDecl>(D))
9142 if (CategoryNames.insert(Category->getIdentifier()).second)
9143 Results.AddResult(
Result(Category, Results.getBasePriority(Category),
9145 SemaRef.CurContext,
nullptr,
false);
9146 Results.ExitScope();
9149 Results.getCompletionContext(), Results.data(),
9174 Results.EnterNewScope();
9175 bool IgnoreImplemented =
true;
9177 for (
const auto *Cat :
Class->visible_categories()) {
9178 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
9179 CategoryNames.insert(Cat->getIdentifier()).second)
9180 Results.AddResult(
Result(Cat, Results.getBasePriority(Cat),
9182 SemaRef.CurContext,
nullptr,
false);
9186 IgnoreImplemented =
false;
9188 Results.ExitScope();
9191 Results.getCompletionContext(), Results.data(),
9202 dyn_cast_or_null<ObjCContainerDecl>(
SemaRef.CurContext);
9209 for (
const auto *D : Container->
decls())
9210 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
9211 Results.Ignore(PropertyImpl->getPropertyDecl());
9215 Results.EnterNewScope();
9217 dyn_cast<ObjCImplementationDecl>(Container))
9220 AddedProperties, Results);
9224 false,
false,
SemaRef.CurContext,
9225 AddedProperties, Results);
9226 Results.ExitScope();
9229 Results.getCompletionContext(), Results.data(),
9242 dyn_cast_or_null<ObjCContainerDecl>(
SemaRef.CurContext);
9250 dyn_cast<ObjCImplementationDecl>(Container))
9251 Class = ClassImpl->getClassInterface();
9255 ->getClassInterface();
9263 Property->getType().getNonReferenceType().getUnqualifiedType();
9266 Results.setPreferredType(PropertyType);
9271 Results.EnterNewScope();
9272 bool SawSimilarlyNamedIvar =
false;
9273 std::string NameWithPrefix;
9274 NameWithPrefix +=
'_';
9275 NameWithPrefix += PropertyName->getName();
9276 std::string NameWithSuffix = PropertyName->getName().str();
9277 NameWithSuffix +=
'_';
9280 Ivar = Ivar->getNextIvar()) {
9281 Results.AddResult(
Result(Ivar, Results.getBasePriority(Ivar),
9283 SemaRef.CurContext,
nullptr,
false);
9287 if ((PropertyName == Ivar->getIdentifier() ||
9288 NameWithPrefix == Ivar->getName() ||
9289 NameWithSuffix == Ivar->getName())) {
9290 SawSimilarlyNamedIvar =
true;
9294 if (Results.size() &&
9295 Results.data()[Results.size() - 1].Kind ==
9297 Results.data()[Results.size() - 1].Declaration == Ivar)
9298 Results.data()[Results.size() - 1].Priority--;
9303 if (!SawSimilarlyNamedIvar) {
9315 Builder.AddTypedTextChunk(Allocator.
CopyString(NameWithPrefix));
9320 Results.ExitScope();
9323 Results.getCompletionContext(), Results.data(),
9330 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
9339 std::optional<bool> WantInstanceMethods,
9342 bool InOriginalClass =
true) {
9345 if (!IFace->hasDefinition())
9348 IFace = IFace->getDefinition();
9352 IFace->getReferencedProtocols();
9354 E = Protocols.
end();
9357 KnownMethods, InOriginalClass);
9360 for (
auto *Cat : IFace->visible_categories()) {
9362 KnownMethods,
false);
9366 if (IFace->getSuperClass())
9368 WantInstanceMethods, ReturnType, KnownMethods,
9375 Category->getReferencedProtocols();
9377 E = Protocols.
end();
9380 KnownMethods, InOriginalClass);
9383 if (InOriginalClass && Category->getClassInterface())
9385 WantInstanceMethods, ReturnType, KnownMethods,
9391 if (!Protocol->hasDefinition())
9393 Protocol = Protocol->getDefinition();
9394 Container = Protocol;
9398 Protocol->getReferencedProtocols();
9400 E = Protocols.
end();
9403 KnownMethods,
false);
9409 for (
auto *M : Container->
methods()) {
9410 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
9411 if (!ReturnType.
isNull() &&
9412 !Context.hasSameUnqualifiedType(ReturnType, M->getReturnType()))
9415 KnownMethods[M->getSelector()] =
9416 KnownMethodsMap::mapped_type(M, InOriginalClass);
9430 Builder.AddTextChunk(Builder.getAllocator().CopyString(Quals));
9431 Builder.AddTextChunk(
9442 if (Class->getIdentifier() && Class->getIdentifier()->getName() == Name)
9451 bool IsInstanceMethod,
9454 ResultBuilder &Results) {
9456 if (!PropName || PropName->
getLength() == 0)
9474 const char *CopiedKey;
9477 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
9479 operator const char *() {
9483 return CopiedKey = Allocator.
CopyString(Key);
9485 } Key(Allocator, PropName->
getName());
9488 std::string UpperKey = std::string(PropName->
getName());
9489 if (!UpperKey.empty())
9492 bool ReturnTypeMatchesProperty =
9495 Property->getType());
9496 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
9499 if (IsInstanceMethod &&
9501 ReturnTypeMatchesProperty && !Property->getGetterMethodDecl()) {
9506 Builder.AddTypedTextChunk(Key);
9513 if (IsInstanceMethod &&
9514 ((!ReturnType.
isNull() &&
9516 (ReturnType.
isNull() && (Property->getType()->isIntegerType() ||
9517 Property->getType()->isBooleanType())))) {
9518 std::string SelectorName = (Twine(
"is") + UpperKey).str();
9522 if (ReturnType.
isNull()) {
9524 Builder.AddTextChunk(
"BOOL");
9535 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
9536 !Property->getSetterMethodDecl()) {
9537 std::string SelectorName = (Twine(
"set") + UpperKey).str();
9539 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9540 if (ReturnType.
isNull()) {
9542 Builder.AddTextChunk(
"void");
9546 Builder.AddTypedTextChunk(
9550 Builder.AddTextChunk(Key);
9561 if (
const auto *ObjCPointer =
9586 if (IsInstanceMethod &&
9588 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
9592 if (ReturnType.
isNull()) {
9594 Builder.AddTextChunk(
"NSUInteger");
9600 Result(Builder.TakeString(),
9601 std::min(IndexedGetterPriority, UnorderedGetterPriority),
9608 if (IsInstanceMethod &&
9610 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
9612 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9613 if (ReturnType.
isNull()) {
9615 Builder.AddTextChunk(
"id");
9619 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9621 Builder.AddTextChunk(
"NSUInteger");
9623 Builder.AddTextChunk(
"index");
9624 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9630 if (IsInstanceMethod &&
9637 std::string SelectorName = (Twine(Property->getName()) +
"AtIndexes").str();
9639 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9640 if (ReturnType.
isNull()) {
9642 Builder.AddTextChunk(
"NSArray *");
9646 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9648 Builder.AddTextChunk(
"NSIndexSet *");
9650 Builder.AddTextChunk(
"indexes");
9651 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9657 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9658 std::string SelectorName = (Twine(
"get") + UpperKey).str();
9659 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName),
9660 &Context.Idents.get(
"range")};
9662 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9663 if (ReturnType.
isNull()) {
9665 Builder.AddTextChunk(
"void");
9669 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9671 Builder.AddPlaceholderChunk(
"object-type");
9672 Builder.AddTextChunk(
" **");
9674 Builder.AddTextChunk(
"buffer");
9676 Builder.AddTypedTextChunk(
"range:");
9678 Builder.AddTextChunk(
"NSRange");
9680 Builder.AddTextChunk(
"inRange");
9681 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9689 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9690 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
9691 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(
"insertObject"),
9692 &Context.Idents.get(SelectorName)};
9694 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9695 if (ReturnType.
isNull()) {
9697 Builder.AddTextChunk(
"void");
9701 Builder.AddTypedTextChunk(
"insertObject:");
9703 Builder.AddPlaceholderChunk(
"object-type");
9704 Builder.AddTextChunk(
" *");
9706 Builder.AddTextChunk(
"object");
9708 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9710 Builder.AddPlaceholderChunk(
"NSUInteger");
9712 Builder.AddTextChunk(
"index");
9713 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9719 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9720 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
9721 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName),
9722 &Context.Idents.get(
"atIndexes")};
9724 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9725 if (ReturnType.
isNull()) {
9727 Builder.AddTextChunk(
"void");
9731 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9733 Builder.AddTextChunk(
"NSArray *");
9735 Builder.AddTextChunk(
"array");
9737 Builder.AddTypedTextChunk(
"atIndexes:");
9739 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9741 Builder.AddTextChunk(
"indexes");
9742 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9748 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9749 std::string SelectorName =
9750 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
9751 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9752 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9753 if (ReturnType.
isNull()) {
9755 Builder.AddTextChunk(
"void");
9759 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9761 Builder.AddTextChunk(
"NSUInteger");
9763 Builder.AddTextChunk(
"index");
9764 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9770 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9771 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
9772 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9773 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9774 if (ReturnType.
isNull()) {
9776 Builder.AddTextChunk(
"void");
9780 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9782 Builder.AddTextChunk(
"NSIndexSet *");
9784 Builder.AddTextChunk(
"indexes");
9785 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9791 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9792 std::string SelectorName =
9793 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
9794 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName),
9795 &Context.Idents.get(
"withObject")};
9797 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9798 if (ReturnType.
isNull()) {
9800 Builder.AddTextChunk(
"void");
9804 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9806 Builder.AddPlaceholderChunk(
"NSUInteger");
9808 Builder.AddTextChunk(
"index");
9810 Builder.AddTypedTextChunk(
"withObject:");
9812 Builder.AddTextChunk(
"id");
9814 Builder.AddTextChunk(
"object");
9815 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9821 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9822 std::string SelectorName1 =
9823 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
9824 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
9825 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName1),
9826 &Context.Idents.get(SelectorName2)};
9828 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9829 if (ReturnType.
isNull()) {
9831 Builder.AddTextChunk(
"void");
9835 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName1 +
":"));
9837 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9839 Builder.AddTextChunk(
"indexes");
9841 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName2 +
":"));
9843 Builder.AddTextChunk(
"NSArray *");
9845 Builder.AddTextChunk(
"array");
9846 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9853 if (IsInstanceMethod &&
9859 ->
getName() ==
"NSEnumerator"))) {
9860 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
9861 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9864 if (ReturnType.
isNull()) {
9866 Builder.AddTextChunk(
"NSEnumerator *");
9870 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
9871 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9877 if (IsInstanceMethod &&
9879 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
9880 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9881 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9882 if (ReturnType.
isNull()) {
9884 Builder.AddPlaceholderChunk(
"object-type");
9885 Builder.AddTextChunk(
" *");
9889 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9891 if (ReturnType.
isNull()) {
9892 Builder.AddPlaceholderChunk(
"object-type");
9893 Builder.AddTextChunk(
" *");
9896 ReturnType, Context, Policy, Builder.getAllocator()));
9899 Builder.AddTextChunk(
"object");
9900 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9907 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9908 std::string SelectorName =
9909 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
9910 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9911 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9912 if (ReturnType.
isNull()) {
9914 Builder.AddTextChunk(
"void");
9918 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9920 Builder.AddPlaceholderChunk(
"object-type");
9921 Builder.AddTextChunk(
" *");
9923 Builder.AddTextChunk(
"object");
9924 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9930 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9931 std::string SelectorName = (Twine(
"add") + UpperKey).str();
9932 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9933 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9934 if (ReturnType.
isNull()) {
9936 Builder.AddTextChunk(
"void");
9940 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9942 Builder.AddTextChunk(
"NSSet *");
9944 Builder.AddTextChunk(
"objects");
9945 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9951 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9952 std::string SelectorName =
9953 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
9954 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9955 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9956 if (ReturnType.
isNull()) {
9958 Builder.AddTextChunk(
"void");
9962 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9964 Builder.AddPlaceholderChunk(
"object-type");
9965 Builder.AddTextChunk(
" *");
9967 Builder.AddTextChunk(
"object");
9968 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9974 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9975 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
9976 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9977 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9978 if (ReturnType.
isNull()) {
9980 Builder.AddTextChunk(
"void");
9984 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9986 Builder.AddTextChunk(
"NSSet *");
9988 Builder.AddTextChunk(
"objects");
9989 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9995 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9996 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
9997 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9998 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9999 if (ReturnType.
isNull()) {
10001 Builder.AddTextChunk(
"void");
10005 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
10007 Builder.AddTextChunk(
"NSSet *");
10009 Builder.AddTextChunk(
"objects");
10010 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
10017 if (!IsInstanceMethod &&
10024 std::string SelectorName =
10025 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
10026 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
10029 if (ReturnType.
isNull()) {
10031 Builder.AddTextChunk(
"NSSet<NSString *> *");
10035 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
10042 if (!IsInstanceMethod &&
10045 std::string SelectorName =
10046 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
10047 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
10050 if (ReturnType.
isNull()) {
10052 Builder.AddTextChunk(
"BOOL");
10056 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
10064 Scope *S, std::optional<bool> IsInstanceMethod,
ParsedType ReturnTy) {
10069 Decl *IDecl =
nullptr;
10070 if (
SemaRef.CurContext->isObjCContainer()) {
10076 bool IsInImplementation =
false;
10077 if (
Decl *D = IDecl) {
10079 SearchDecl = Impl->getClassInterface();
10080 IsInImplementation =
true;
10082 dyn_cast<ObjCCategoryImplDecl>(D)) {
10083 SearchDecl = CatImpl->getCategoryDecl();
10084 IsInImplementation =
true;
10086 SearchDecl = dyn_cast<ObjCContainerDecl>(D);
10089 if (!SearchDecl && S) {
10091 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
10110 Results.EnterNewScope();
10112 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
10113 MEnd = KnownMethods.end();
10117 Results.getCodeCompletionTUInfo());
10120 if (!IsInstanceMethod) {
10121 Builder.AddTextChunk(
Method->isInstanceMethod() ?
"-" :
"+");
10127 if (ReturnType.
isNull()) {
10128 QualType ResTy =
Method->getSendResultType().stripObjCKindOfType(Context);
10129 AttributedType::stripOuterNullability(ResTy);
10138 Builder.AddTypedTextChunk(
10144 PEnd =
Method->param_end();
10145 P != PEnd; (
void)++P, ++I) {
10148 Builder.AddTypedTextChunk(
10149 Builder.getAllocator().CopyString(Sel.
getNameForSlot(I) +
":"));
10152 Builder.AddTypedTextChunk(
10153 Builder.getAllocator().CopyString(Sel.
getNameForSlot(I) +
":"));
10160 ParamType = (*P)->getType();
10162 ParamType = (*P)->getOriginalType();
10165 AttributedType::stripOuterNullability(ParamType);
10167 Context, Policy, Builder);
10170 Builder.AddTextChunk(
10171 Builder.getAllocator().CopyString(Id->getName()));
10175 if (
Method->isVariadic()) {
10176 if (
Method->param_size() > 0)
10178 Builder.AddTextChunk(
"...");
10181 if (IsInImplementation && Results.includeCodePatterns()) {
10186 if (!
Method->getReturnType()->isVoidType()) {
10188 Builder.AddTextChunk(
"return");
10190 Builder.AddPlaceholderChunk(
"expression");
10193 Builder.AddPlaceholderChunk(
"statements");
10200 auto R =
Result(Builder.TakeString(),
Method, Priority);
10201 if (!M->second.getInt())
10203 Results.AddResult(std::move(R));
10208 if (Context.getLangOpts().ObjC) {
10210 Containers.push_back(SearchDecl);
10213 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
10214 MEnd = KnownMethods.end();
10216 KnownSelectors.insert(M->first);
10221 IFace = Category->getClassInterface();
10226 if (IsInstanceMethod) {
10227 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
10228 for (
auto *P : Containers[I]->instance_properties())
10230 KnownSelectors, Results);
10234 Results.ExitScope();
10237 Results.getCompletionContext(), Results.data(),
10242 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
10246 if (
SemaRef.ExternalSource) {
10247 for (uint32_t I = 0, N =
SemaRef.ExternalSource->GetNumExternalSelectors();
10253 SemaRef.ObjC().ReadMethodPool(Sel);
10264 Results.setPreferredType(
10265 SemaRef.GetTypeFromParser(ReturnTy).getNonReferenceType());
10267 Results.EnterNewScope();
10268 for (SemaObjC::GlobalMethodPool::iterator
10269 M =
SemaRef.ObjC().MethodPool.begin(),
10270 MEnd =
SemaRef.ObjC().MethodPool.end();
10272 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
10273 : &M->second.second;
10274 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
10278 if (AtParameterName) {
10280 unsigned NumSelIdents = SelIdents.size();
10281 if (NumSelIdents &&
10282 NumSelIdents <= MethList->getMethod()->param_size()) {
10284 MethList->getMethod()->parameters()[NumSelIdents - 1];
10285 if (Param->getIdentifier()) {
10287 Results.getCodeCompletionTUInfo());
10288 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
10289 Param->getIdentifier()->getName()));
10290 Results.AddResult(Builder.TakeString());
10297 Result R(MethList->getMethod(),
10298 Results.getBasePriority(MethList->getMethod()),
10300 R.StartParameter = SelIdents.size();
10301 R.AllParametersAreInformative =
false;
10302 R.DeclaringEntity =
true;
10303 Results.MaybeAddResult(R,
SemaRef.CurContext);
10307 Results.ExitScope();
10309 if (!AtParameterName && !SelIdents.empty() &&
10310 SelIdents.front()->getName().starts_with(
"init")) {
10311 for (
const auto &M :
SemaRef.PP.macros()) {
10312 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
10314 Results.EnterNewScope();
10316 Results.getCodeCompletionTUInfo());
10317 Builder.AddTypedTextChunk(
10318 Builder.getAllocator().CopyString(M.first->getName()));
10321 Results.ExitScope();
10326 Results.getCompletionContext(), Results.data(),
10334 Results.EnterNewScope();
10338 Results.getCodeCompletionTUInfo());
10339 Builder.AddTypedTextChunk(
"if");
10341 Builder.AddPlaceholderChunk(
"condition");
10342 Results.AddResult(Builder.TakeString());
10345 Builder.AddTypedTextChunk(
"ifdef");
10347 Builder.AddPlaceholderChunk(
"macro");
10348 Results.AddResult(Builder.TakeString());
10351 Builder.AddTypedTextChunk(
"ifndef");
10353 Builder.AddPlaceholderChunk(
"macro");
10354 Results.AddResult(Builder.TakeString());
10356 if (InConditional) {
10358 Builder.AddTypedTextChunk(
"elif");
10360 Builder.AddPlaceholderChunk(
"condition");
10361 Results.AddResult(Builder.TakeString());
10364 Builder.AddTypedTextChunk(
"elifdef");
10366 Builder.AddPlaceholderChunk(
"macro");
10367 Results.AddResult(Builder.TakeString());
10370 Builder.AddTypedTextChunk(
"elifndef");
10372 Builder.AddPlaceholderChunk(
"macro");
10373 Results.AddResult(Builder.TakeString());
10376 Builder.AddTypedTextChunk(
"else");
10377 Results.AddResult(Builder.TakeString());
10380 Builder.AddTypedTextChunk(
"endif");
10381 Results.AddResult(Builder.TakeString());
10385 Builder.AddTypedTextChunk(
"include");
10387 Builder.AddTextChunk(
"\"");
10388 Builder.AddPlaceholderChunk(
"header");
10389 Builder.AddTextChunk(
"\"");
10390 Results.AddResult(Builder.TakeString());
10393 Builder.AddTypedTextChunk(
"include");
10395 Builder.AddTextChunk(
"<");
10396 Builder.AddPlaceholderChunk(
"header");
10397 Builder.AddTextChunk(
">");
10398 Results.AddResult(Builder.TakeString());
10401 Builder.AddTypedTextChunk(
"define");
10403 Builder.AddPlaceholderChunk(
"macro");
10404 Results.AddResult(Builder.TakeString());
10407 Builder.AddTypedTextChunk(
"define");
10409 Builder.AddPlaceholderChunk(
"macro");
10411 Builder.AddPlaceholderChunk(
"args");
10413 Results.AddResult(Builder.TakeString());
10416 Builder.AddTypedTextChunk(
"undef");
10418 Builder.AddPlaceholderChunk(
"macro");
10419 Results.AddResult(Builder.TakeString());
10422 Builder.AddTypedTextChunk(
"line");
10424 Builder.AddPlaceholderChunk(
"number");
10425 Results.AddResult(Builder.TakeString());
10428 Builder.AddTypedTextChunk(
"line");
10430 Builder.AddPlaceholderChunk(
"number");
10432 Builder.AddTextChunk(
"\"");
10433 Builder.AddPlaceholderChunk(
"filename");
10434 Builder.AddTextChunk(
"\"");
10435 Results.AddResult(Builder.TakeString());
10438 Builder.AddTypedTextChunk(
"error");
10440 Builder.AddPlaceholderChunk(
"message");
10441 Results.AddResult(Builder.TakeString());
10444 Builder.AddTypedTextChunk(
"pragma");
10446 Builder.AddPlaceholderChunk(
"arguments");
10447 Results.AddResult(Builder.TakeString());
10451 Builder.AddTypedTextChunk(
"import");
10453 Builder.AddTextChunk(
"\"");
10454 Builder.AddPlaceholderChunk(
"header");
10455 Builder.AddTextChunk(
"\"");
10456 Results.AddResult(Builder.TakeString());
10459 Builder.AddTypedTextChunk(
"import");
10461 Builder.AddTextChunk(
"<");
10462 Builder.AddPlaceholderChunk(
"header");
10463 Builder.AddTextChunk(
">");
10464 Results.AddResult(Builder.TakeString());
10468 Builder.AddTypedTextChunk(
"include_next");
10470 Builder.AddTextChunk(
"\"");
10471 Builder.AddPlaceholderChunk(
"header");
10472 Builder.AddTextChunk(
"\"");
10473 Results.AddResult(Builder.TakeString());
10476 Builder.AddTypedTextChunk(
"include_next");
10478 Builder.AddTextChunk(
"<");
10479 Builder.AddPlaceholderChunk(
"header");
10480 Builder.AddTextChunk(
">");
10481 Results.AddResult(Builder.TakeString());
10484 Builder.AddTypedTextChunk(
"warning");
10486 Builder.AddPlaceholderChunk(
"message");
10487 Results.AddResult(Builder.TakeString());
10491 Builder.AddTypedTextChunk(
"embed");
10493 Builder.AddTextChunk(
"\"");
10494 Builder.AddPlaceholderChunk(
"file");
10495 Builder.AddTextChunk(
"\"");
10496 Results.AddResult(Builder.TakeString());
10499 Builder.AddTypedTextChunk(
"embed");
10501 Builder.AddTextChunk(
"<");
10502 Builder.AddPlaceholderChunk(
"file");
10503 Builder.AddTextChunk(
">");
10504 Results.AddResult(Builder.TakeString());
10512 Results.ExitScope();
10515 Results.getCompletionContext(), Results.data(),
10534 Results.getCodeCompletionTUInfo());
10535 Results.EnterNewScope();
10536 for (
const auto &M :
SemaRef.PP.macros()) {
10537 Builder.AddTypedTextChunk(
10538 Builder.getAllocator().CopyString(M.first->getName()));
10542 Results.ExitScope();
10543 }
else if (IsDefinition) {
10548 Results.getCompletionContext(), Results.data(),
10561 Results.EnterNewScope();
10563 Results.getCodeCompletionTUInfo());
10564 Builder.AddTypedTextChunk(
"defined");
10567 Builder.AddPlaceholderChunk(
"macro");
10569 Results.AddResult(Builder.TakeString());
10570 Results.ExitScope();
10573 Results.getCompletionContext(), Results.data(),
10593 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
10596 llvm::sys::path::native(NativeRelDir);
10597 llvm::vfs::FileSystem &FS =
10598 SemaRef.getSourceManager().getFileManager().getVirtualFileSystem();
10603 llvm::DenseSet<StringRef> SeenResults;
10606 auto AddCompletion = [&](StringRef Filename,
bool IsDirectory) {
10609 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
10610 auto R = SeenResults.insert(TypedChunk);
10612 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
10613 *R.first = InternedTyped;
10616 Builder.AddTypedTextChunk(InternedTyped);
10624 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
10628 if (!NativeRelDir.empty()) {
10632 auto Begin = llvm::sys::path::begin(NativeRelDir);
10633 auto End = llvm::sys::path::end(NativeRelDir);
10635 llvm::sys::path::append(Dir, *Begin +
".framework",
"Headers");
10636 llvm::sys::path::append(Dir, ++Begin, End);
10638 llvm::sys::path::append(Dir, NativeRelDir);
10642 const StringRef &Dirname = llvm::sys::path::filename(Dir);
10643 const bool isQt = Dirname.starts_with(
"Qt") || Dirname ==
"ActiveQt";
10644 const bool ExtensionlessHeaders =
10645 IsSystem || isQt || Dir.ends_with(
".framework/Headers") ||
10646 IncludeDir.ends_with(
"/include") || IncludeDir.ends_with(
"\\include");
10647 std::error_code EC;
10648 unsigned Count = 0;
10649 for (
auto It = FS.dir_begin(Dir, EC);
10650 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
10651 if (++Count == 2500)
10653 StringRef Filename = llvm::sys::path::filename(It->path());
10658 llvm::sys::fs::file_type
Type = It->type();
10659 if (
Type == llvm::sys::fs::file_type::symlink_file) {
10660 if (
auto FileStatus = FS.status(It->path()))
10661 Type = FileStatus->getType();
10664 case llvm::sys::fs::file_type::directory_file:
10668 NativeRelDir.empty() && !Filename.consume_back(
".framework"))
10671 AddCompletion(Filename,
true);
10673 case llvm::sys::fs::file_type::regular_file: {
10675 const bool IsHeader = Filename.ends_with_insensitive(
".h") ||
10676 Filename.ends_with_insensitive(
".hh") ||
10677 Filename.ends_with_insensitive(
".hpp") ||
10678 Filename.ends_with_insensitive(
".hxx") ||
10679 Filename.ends_with_insensitive(
".inc") ||
10680 (ExtensionlessHeaders && !Filename.contains(
'.'));
10683 AddCompletion(Filename,
false);
10695 switch (IncludeDir.getLookupType()) {
10700 AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
10704 AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
10713 const auto &S =
SemaRef.PP.getHeaderSearchInfo();
10714 using llvm::make_range;
10717 if (
auto CurFile =
SemaRef.PP.getCurrentFileLexer()->getFileEntry())
10718 AddFilesFromIncludeDir(CurFile->getDir().getName(),
false,
10720 for (
const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
10721 AddFilesFromDirLookup(D,
false);
10723 for (
const auto &D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
10724 AddFilesFromDirLookup(D,
false);
10725 for (
const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
10726 AddFilesFromDirLookup(D,
true);
10729 Results.getCompletionContext(), Results.data(),
10743 Results.EnterNewScope();
10744 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
10748 Twine(Platform) +
"ApplicationExtension")));
10750 Results.ExitScope();
10752 Results.getCompletionContext(), Results.data(),
10759 ResultBuilder Builder(
SemaRef, Allocator, CCTUInfo,
10762 CodeCompletionDeclConsumer Consumer(
10774 Results.insert(Results.end(), Builder.data(),
10775 Builder.data() + Builder.size());
This file provides AST data structures related to concepts.
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc QualifierLoc)
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
Result
Implement __builtin_bit_cast and related operations.
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 AccessResult IsAccessible(Sema &S, const EffectiveContext &EC, AccessTarget &Entity, TemplateSpecCandidateSet *FailedTSC)
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 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 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 void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
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 CodeCompletionString * createTemplateSignatureString(const TemplateDecl *TD, CodeCompletionBuilder &Builder, unsigned CurrentArg, const PrintingPolicy &Policy)
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
static void AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
static const NamedDecl * extractFunctorCallOperator(const NamedDecl *ND)
static void AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
static QualType ProduceSignatureHelp(Sema &SemaRef, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, SourceLocation OpenParLoc, bool Braced)
static std::string FormatFunctionParameter(const PrintingPolicy &Policy, const DeclaratorDecl *Param, bool SuppressName=false, bool SuppressBlock=false, std::optional< ArrayRef< QualType > > ObjCSubsts=std::nullopt)
static void AddFunctionParameterChunks(Preprocessor &PP, const PrintingPolicy &Policy, const FunctionDecl *Function, CodeCompletionBuilder &Result, unsigned Start=0, bool InOptional=false, bool FunctionCanBeCall=true, bool IsInDeclarationContext=false)
Add function parameter chunks to the given code completion string.
static RecordDecl * getAsRecordDecl(QualType BaseType, HeuristicResolver &Resolver)
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 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 QualType getDesignatedType(ASTContext &Context, QualType BaseType, const Designation &Desig, HeuristicResolver &Resolver, llvm::function_ref< const FieldDecl *(RecordDecl *, const Designator &)> LookupField)
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 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 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 void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function, bool AsInformativeChunks=true)
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 OverloadCompare compareOverloads(const CXXMethodDecl &Candidate, const CXXMethodDecl &Incumbent, const Qualifiers &ObjectQuals, ExprValueKind ObjectKind, const ASTContext &Ctx)
static const FieldDecl * lookupDirectField(RecordDecl *RD, const Designator &D)
static void AddTemplateParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const TemplateDecl *Template, CodeCompletionBuilder &Result, unsigned MaxParameters=0, unsigned Start=0, bool InDefaultArg=false, bool AsInformativeChunk=false)
Add template parameter chunks to the given code completion string.
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 AddFunctionTypeQuals(CodeCompletionBuilder &Result, const Qualifiers Quals, bool AsInformativeChunk=true)
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 AddFunctionExceptSpecToCompletionString(std::string &NameAndSignature, const FunctionDecl *Function)
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.
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 ...
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
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 getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const RawComment * getRawCommentForAnyRedecl(RawCommentLookupKey Key, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration or macro.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Syntax
The style used to specify an attribute.
Type source information for an attributed type.
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.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
QualType getBaseType() const
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Represents a static or instance method of a struct/union/class.
overridden_method_range overridden_methods() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
Qualifiers getMethodQualifiers() const
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.
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.
CaseStmt - Represent a case statement.
Represents a byte-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 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 AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional 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, functionor 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)
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.
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.
NestedNameSpecifier Qualifier
If the result should have a nested-name-specifier, this is it.
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 ...
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 ('<').
Expr * getConstraintExpr() const
const TypeClass * getTypePtr() const
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isRequiresExprBody() const
bool isFileContext() const
DeclContextLookupResult lookup_result
ASTContext & getParentASTContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
decl_iterator decls_end() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically 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
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.
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
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
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.
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
DeclaratorContext getContext() const
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
bool isStaticMember()
Returns true if this declares a static member.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Designation - Represent a full designation, which is a sequence of designators.
const Designator & getDesignator(unsigned Idx) const
unsigned getNumDesignators() const
Designator - A designator in a C99 designated initializer.
const IdentifierInfo * getFieldDecl() const
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
virtual bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
This represents one expression.
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.
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.
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.
const ParmVarDecl * getParamDecl(unsigned i) const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
ArrayRef< ParmVarDecl * > parameters() const
bool isVariadic() const
Whether this function is variadic.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Represents a prototype with parameter type info, e.g.
ExceptionSpecInfo getExceptionSpecInfo() const
Return all the available information about this type's exception spec.
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
QualType simplifyType(QualType Type, const Expr *E, bool UnwrapPointer)
TagDecl * resolveTypeToTagDecl(QualType T) const
QualType resolveExprToType(const Expr *E) 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.
A simple pair of identifier info and location.
const TypeClass * getTypePtr() const
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.
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.
Describes a module or submodule.
@ AllVisible
All of the names in this module are visible.
ModuleKind Kind
The kind of this module.
llvm::iterator_range< submodule_iterator > submodules()
@ ImplicitGlobalModuleFragment
This is an implicit fragment of the global module which contains only language linkage declarations (...
@ ModulePartitionInterface
This is a C++20 module partition interface.
@ ModuleInterfaceUnit
This is a C++20 module interface unit.
@ PrivateModuleFragment
This is the private module fragment within some C++ module.
@ ExplicitGlobalModuleFragment
This is the explicit Global Module Fragment of a modular TU.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine if the declaration obeys the reserved identifier rules of the given language.
Represent a C++ namespace.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false, bool PrintFinalScopeResOp=true) const
Print this nested name specifier to the given output stream.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
const Type * getAsType() const
@ Type
A type, stored as a Type*.
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.
method_range methods() const
instprop_range instance_properties() const
classprop_range class_properties() const
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.
unsigned param_size() const
param_const_iterator param_end() const
param_const_iterator param_begin() const
const ParmVarDecl *const * param_const_iterator
Selector getSelector() const
bool isInstanceMethod() 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 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_CodeCompletion
When doing overload resolution during code completion, we want to show all viable candidates,...
CandidateSetKind getKind() const
Represents a parameter to a function.
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.
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.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
llvm::iterator_range< macro_iterator > macros(bool IncludeExternalMacros=true) const
SourceManager & getSourceManager() const
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
bool isMacroDefined(StringRef Id)
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.
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 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 hasOnlyConst() const
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
bool hasOnlyVolatile() const
bool hasOnlyRestrict() const
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
field_range fields() const
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
unsigned getFlags() const
getFlags - Return the flags for this scope.
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
DeclContext * getEntity() const
Get the entity corresponding to this scope.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
bool isClassInheritanceScope() const
Determines whether this scope is between inheritance colon and the real class/struct definition.
@ 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
ASTContext & getASTContext() const
const LangOptions & getLangOpts() 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 CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, bool IsUsingDeclaration, bool IsAddressOfOperand, bool IsInDeclarationContext, QualType BaseType, QualType PreferredType)
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 CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data, bool IsAddressOfOperand=false)
Perform code-completion in an expression context when we know what type we're looking for.
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)
OpaquePtr< TemplateName > TemplateTy
HeuristicResolver Resolver
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 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)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
void CodeCompleteNaturalLanguage()
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, const IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
void CodeCompleteInitializer(Scope *S, Decl *D)
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLoc > Protocols)
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 CodeCompleteOffsetOfDesignator(QualType BaseType, const Designation &D)
Trigger code completion for a position inside a __builtin_offsetof member designator (after the type'...
void CodeCompleteBracketDeclarator(Scope *S)
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteKeywordAfterIf(bool AfterExclaim) const
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)
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.
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.
Preprocessor & getPreprocessor() const
ASTContext & getASTContext() const
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...
const LangOptions & getLangOpts() const
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
SemaCodeCompletion & CodeCompletion()
sema::FunctionScopeInfo * getCurFunction() const
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
ExternalSemaSource * getExternalSource() const
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...
SourceManager & SourceMgr
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
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.
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.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
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.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
NamedDecl ** iterator
Iterates through the template parameters in this list.
bool hasParameterPack() const
Determine whether this template parameter list contains a parameter pack.
ArrayRef< NamedDecl * > asArray()
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.
The top declaration context.
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.
bool isBlockPointerType() const
bool isBooleanType() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
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
NestedNameSpecifier getPrefix() const
If this type represents a qualified-id, this returns its nested name specifier.
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 isMemberPointerType() const
bool isObjCIdType() const
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...
const T * getAs() const
Member-template getAs<specific type>'.
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...
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.
@ 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...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
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.
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
bool isa(CodeGen::Address addr)
@ CCP_Type
Priority for a type.
@ CCP_ObjC_cmd
Priority for the Objective-C "_cmd" implicit parameter.
@ CCP_Keyword
Priority for a language keyword (that isn't any of the other categories).
@ CCP_Macro
Priority for a preprocessor macro.
@ CCP_LocalDeclaration
Priority for a declaration that is in the local scope.
@ CCP_Unlikely
Priority for a result that isn't likely to be what the user wants, but is included for completeness.
@ CCP_NestedNameSpecifier
Priority for a nested-name-specifier.
@ CCP_SuperCompletion
Priority for a send-to-super completion.
@ CCP_NextInitializer
Priority for the next initialization in a constructor initializer list.
@ CCP_Declaration
Priority for a non-type declaration.
@ CCP_Constant
Priority for a constant value (e.g., enumerator).
@ CCP_MemberDeclaration
Priority for a member declaration found from the current method or member function.
@ CCP_EnumInCase
Priority for an enumeration constant inside a switch whose condition is of the enumeration type.
@ CCP_CodePattern
Priority for a code pattern.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind, bool PartialOverloading=false)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
bool isReservedInAllContexts(ReservedIdentifierStatus Status)
Determine whether an identifier is reserved in all contexts.
ArrayRef< IdentifierLoc > ModuleIdPath
A sequence of identifier/location pairs used to describe a particular module or submodule,...
@ 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.
@ 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.
@ IK_ConstructorName
A constructor name.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ 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 FunctionProtoType * T
@ Template
We are parsing a template declaration.
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern.
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
@ NonType
The name was classified as a specific non-type, non-template declaration.
@ OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
const RawComment * getCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Declaration.
@ 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....
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
@ Deduced
The normal deduced case.
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.
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)
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor
U cast(CodeGen::Address addr)
@ Enumerator
Enumerator value with fixed underlying type.
QualType getDeclUsageType(ASTContext &C, NestedNameSpecifier Qualifier, const NamedDecl *ND)
Determine the type that this declaration will have if it is used as a type or in an expression.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ StartsWithDoubleUnderscore
ActionResult< Expr * > ExprResult
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
bool IntegralConstantExpression
SmallVector< Decl *, 4 > IgnoreDecls
CodeCompleteExpressionData(QualType PreferredType=QualType(), bool IsParenthesized=false)
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Represents a complete lambda introducer.
SmallVector< LambdaCapture, 4 > Captures
LambdaCaptureDefault Default
a linked list of methods with the same selector name but different signatures.
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 SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
@ Plain
E.g., (anonymous enum)/(unnamed struct)/etc.
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.
unsigned ResolveDecltype
Use whitespace and punctuation like MSVC does.
unsigned AnonymousTagNameStyle