48#include "llvm/ADT/ArrayRef.h"
49#include "llvm/ADT/DenseSet.h"
50#include "llvm/ADT/SmallBitVector.h"
51#include "llvm/ADT/SmallPtrSet.h"
52#include "llvm/ADT/SmallString.h"
53#include "llvm/ADT/StringSet.h"
54#include "llvm/ADT/StringSwitch.h"
55#include "llvm/ADT/Twine.h"
56#include "llvm/ADT/iterator_range.h"
57#include "llvm/Support/Casting.h"
58#include "llvm/Support/FileSystem.h"
59#include "llvm/Support/Path.h"
60#include "llvm/Support/VirtualFileSystem.h"
61#include "llvm/Support/raw_ostream.h"
80 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
82 typedef CodeCompletionResult Result;
86 std::vector<Result> Results;
91 llvm::SmallPtrSet<const Decl *, 16> AllDeclsFound;
93 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
98 class ShadowMapEntry {
99 typedef SmallVector<DeclIndexPair, 4> DeclIndexPairVector;
103 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector *> DeclOrVector;
107 unsigned SingleDeclIndex = 0;
110 ShadowMapEntry() =
default;
111 ShadowMapEntry(
const ShadowMapEntry &) =
delete;
112 ShadowMapEntry(ShadowMapEntry &&Move) { *
this = std::move(Move); }
113 ShadowMapEntry &operator=(
const ShadowMapEntry &) =
delete;
114 ShadowMapEntry &operator=(ShadowMapEntry &&Move) {
115 SingleDeclIndex =
Move.SingleDeclIndex;
116 DeclOrVector =
Move.DeclOrVector;
117 Move.DeclOrVector =
nullptr;
121 void Add(
const NamedDecl *ND,
unsigned Index) {
122 if (DeclOrVector.isNull()) {
125 SingleDeclIndex = Index;
129 if (
const NamedDecl *PrevND = dyn_cast<const NamedDecl *>(DeclOrVector)) {
132 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
133 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
139 ->push_back(DeclIndexPair(ND, Index));
143 if (DeclIndexPairVector *Vec =
144 dyn_cast_if_present<DeclIndexPairVector *>(DeclOrVector)) {
146 DeclOrVector = ((NamedDecl *)
nullptr);
159 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
166 CodeCompletionAllocator &Allocator;
168 CodeCompletionTUInfo &CCTUInfo;
176 bool AllowNestedNameSpecifiers;
187 std::list<ShadowMap> ShadowMaps;
191 llvm::DenseMap<std::pair<DeclContext *,
uintptr_t>, ShadowMapEntry>
196 Qualifiers ObjectTypeQualifiers;
201 bool HasObjectTypeQualifiers;
204 bool IsExplicitObjectMemberFunction;
207 Selector PreferredSelector;
210 CodeCompletionContext CompletionContext;
214 ObjCImplementationDecl *ObjCImplementation;
216 void AdjustResultPriorityForDecl(Result &R);
218 void MaybeAddConstructorResults(Result R);
221 explicit ResultBuilder(Sema &SemaRef, CodeCompletionAllocator &Allocator,
222 CodeCompletionTUInfo &CCTUInfo,
223 const CodeCompletionContext &CompletionContext,
224 LookupFilter Filter =
nullptr)
225 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
226 Filter(Filter), AllowNestedNameSpecifiers(
false),
227 HasObjectTypeQualifiers(
false), IsExplicitObjectMemberFunction(
false),
228 CompletionContext(CompletionContext), ObjCImplementation(
nullptr) {
231 switch (CompletionContext.getKind()) {
232 case CodeCompletionContext::CCC_Expression:
233 case CodeCompletionContext::CCC_ObjCMessageReceiver:
234 case CodeCompletionContext::CCC_ParenthesizedExpression:
235 case CodeCompletionContext::CCC_Statement:
236 case CodeCompletionContext::CCC_TopLevelOrExpression:
237 case CodeCompletionContext::CCC_Recovery:
238 if (ObjCMethodDecl *Method = SemaRef.getCurMethodDecl())
239 if (Method->isInstanceMethod())
240 if (ObjCInterfaceDecl *Interface = Method->getClassInterface())
241 ObjCImplementation = Interface->getImplementation();
250 unsigned getBasePriority(
const NamedDecl *D);
254 bool includeCodePatterns()
const {
255 return SemaRef.CodeCompletion().CodeCompleter &&
256 SemaRef.CodeCompletion().CodeCompleter->includeCodePatterns();
260 void setFilter(LookupFilter Filter) { this->Filter = Filter; }
262 Result *data() {
return Results.empty() ?
nullptr : &Results.front(); }
263 unsigned size()
const {
return Results.size(); }
264 bool empty()
const {
return Results.empty(); }
267 void setPreferredType(QualType
T) {
268 PreferredType = SemaRef.Context.getCanonicalType(
T);
278 void setObjectTypeQualifiers(Qualifiers Quals,
ExprValueKind Kind) {
279 ObjectTypeQualifiers = Quals;
281 HasObjectTypeQualifiers =
true;
284 void setExplicitObjectMemberFn(
bool IsExplicitObjectFn) {
285 IsExplicitObjectMemberFunction = IsExplicitObjectFn;
293 void setPreferredSelector(Selector Sel) { PreferredSelector = Sel; }
297 const CodeCompletionContext &getCompletionContext()
const {
298 return CompletionContext;
302 void allowNestedNameSpecifiers(
bool Allow =
true) {
303 AllowNestedNameSpecifiers =
Allow;
308 Sema &getSema()
const {
return SemaRef; }
311 CodeCompletionAllocator &getAllocator()
const {
return Allocator; }
313 CodeCompletionTUInfo &getCodeCompletionTUInfo()
const {
return CCTUInfo; }
322 bool isInterestingDecl(
const NamedDecl *ND,
323 bool &AsNestedNameSpecifier)
const;
331 bool canFunctionBeCalled(
const NamedDecl *ND, QualType BaseExprType)
const;
339 bool canCxxMethodBeCalled(
const CXXMethodDecl *
Method,
340 QualType BaseExprType)
const;
348 bool CheckHiddenResult(Result &R, DeclContext *CurContext,
349 const NamedDecl *Hiding);
358 void MaybeAddResult(Result R, DeclContext *CurContext =
nullptr);
374 void AddResult(Result R, DeclContext *CurContext, NamedDecl *Hiding,
375 bool InBaseClass, QualType BaseExprType,
376 bool IsInDeclarationContext,
bool IsAddressOfOperand);
379 void AddResult(Result R);
382 void EnterNewScope();
391 void addVisitedContext(DeclContext *Ctx) {
392 CompletionContext.addVisitedContext(Ctx);
401 bool IsOrdinaryName(
const NamedDecl *ND)
const;
402 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
403 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
404 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
405 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
406 bool IsEnum(
const NamedDecl *ND)
const;
407 bool IsClassOrStruct(
const NamedDecl *ND)
const;
408 bool IsUnion(
const NamedDecl *ND)
const;
409 bool IsNamespace(
const NamedDecl *ND)
const;
410 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
411 bool IsType(
const NamedDecl *ND)
const;
412 bool IsMember(
const NamedDecl *ND)
const;
413 bool IsOffsetofField(
const NamedDecl *ND)
const;
414 bool IsObjCIvar(
const NamedDecl *ND)
const;
415 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
416 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
417 bool IsObjCCollection(
const NamedDecl *ND)
const;
418 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
431 for (
auto *Redecl : Function->getFirstDecl()->redecls()) {
435 if (Redecl->getNumParams() < ParaCount)
437 for (
unsigned P = Start, N = Redecl->getNumParams(); P != N; ++P)
438 if (Redecl->getParamDecl(P)->getIdentifier())
450 ComputeType =
nullptr;
451 Type = BSI->ReturnType;
455 ComputeType =
nullptr;
459 ComputeType =
nullptr;
460 Type =
Method->getReturnType();
468 auto *VD = llvm::dyn_cast_or_null<ValueDecl>(D);
469 ComputeType =
nullptr;
470 Type = VD ? VD->getType() :
QualType();
486 ComputeType =
nullptr;
496 this->ComputeType = ComputeType;
506 if (ExpectedLoc == LParLoc)
517 if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
520 if (Op == tok::minus)
533 case tok::minusequal:
535 case tok::percentequal:
537 case tok::slashequal:
543 case tok::equalequal:
544 case tok::exclaimequal:
548 case tok::greaterequal:
552 case tok::greatergreater:
553 case tok::greatergreaterequal:
555 case tok::lesslessequal:
568 case tok::caretequal:
576 case tok::periodstar:
594 if (!ContextType.isNull() && ContextType->isPointerType())
595 return ContextType->getPointeeType();
598 if (ContextType.isNull())
604 case tok::minusminus:
606 if (ContextType.isNull())
614 assert(
false &&
"unhandled unary op");
623 ComputeType =
nullptr;
630 if (!Enabled || !
Base)
633 if (ExpectedLoc !=
Base->getBeginLoc())
644 ComputeType =
nullptr;
653 ComputeType =
nullptr;
662 ComputeType =
nullptr;
670 ComputeType =
nullptr;
676 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
677 unsigned SingleDeclIndex;
689 pointer(
const DeclIndexPair &Value) : Value(Value) {}
697 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) {}
700 : DeclOrIterator(Iterator), SingleDeclIndex(0) {}
722 if (
const NamedDecl *ND = dyn_cast<const NamedDecl *>(DeclOrIterator))
731 return X.DeclOrIterator.getOpaqueValue() ==
732 Y.DeclOrIterator.getOpaqueValue() &&
733 X.SingleDeclIndex == Y.SingleDeclIndex;
742ResultBuilder::ShadowMapEntry::begin()
const {
743 if (DeclOrVector.isNull())
746 if (
const NamedDecl *ND = dyn_cast<const NamedDecl *>(DeclOrVector))
747 return iterator(ND, SingleDeclIndex);
753ResultBuilder::ShadowMapEntry::end()
const {
778 for (
const DeclContext *CommonAncestor = TargetContext;
779 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
780 CommonAncestor = CommonAncestor->getLookupParent()) {
781 if (CommonAncestor->isTransparentContext() ||
782 CommonAncestor->isFunctionOrMethod())
785 TargetParents.push_back(CommonAncestor);
789 while (!TargetParents.empty()) {
790 const DeclContext *Parent = TargetParents.pop_back_val();
792 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
793 if (!Namespace->getIdentifier())
797 }
else if (
const auto *TD = dyn_cast<TagDecl>(Parent)) {
830bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
831 bool &AsNestedNameSpecifier)
const {
832 AsNestedNameSpecifier =
false;
858 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
860 Filter != &ResultBuilder::IsNamespaceOrAlias && Filter !=
nullptr))
861 AsNestedNameSpecifier =
true;
864 if (Filter && !(this->*Filter)(Named)) {
866 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
867 IsNestedNameSpecifier(ND) &&
868 (Filter != &ResultBuilder::IsMember ||
871 AsNestedNameSpecifier =
true;
890 R.Declaration->getDeclContext()->getRedeclContext();
901 R.QualifierIsInformative =
false;
905 R.Declaration->getDeclContext());
912 switch (
T->getTypeClass()) {
915 case BuiltinType::Void:
918 case BuiltinType::NullPtr:
921 case BuiltinType::Overload:
922 case BuiltinType::Dependent:
925 case BuiltinType::ObjCId:
926 case BuiltinType::ObjCClass:
927 case BuiltinType::ObjCSel:
940 case Type::BlockPointer:
943 case Type::LValueReference:
944 case Type::RValueReference:
947 case Type::ConstantArray:
948 case Type::IncompleteArray:
949 case Type::VariableArray:
950 case Type::DependentSizedArray:
953 case Type::DependentSizedExtVector:
955 case Type::ExtVector:
958 case Type::FunctionProto:
959 case Type::FunctionNoProto:
968 case Type::ObjCObject:
969 case Type::ObjCInterface:
970 case Type::ObjCObjectPointer:
984 if (
const auto *
Type = dyn_cast<TypeDecl>(ND))
986 if (
const auto *Iface = dyn_cast<ObjCInterfaceDecl>(ND))
987 return C.getObjCInterfaceType(Iface);
992 else if (
const auto *
Method = dyn_cast<ObjCMethodDecl>(ND))
993 T =
Method->getSendResultType();
994 else if (
const auto *
Enumerator = dyn_cast<EnumConstantDecl>(ND))
998 else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND))
1000 else if (
const auto *
Value = dyn_cast<ValueDecl>(ND))
1011 T = Ref->getPointeeType();
1016 if (
Pointer->getPointeeType()->isFunctionType()) {
1025 T =
Block->getPointeeType();
1040unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
1048 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
1049 if (ImplicitParam->getIdentifier() &&
1050 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
1079 CompletionContext.
getKind() ==
1081 CompletionContext.
getKind() ==
1088void ResultBuilder::AdjustResultPriorityForDecl(
Result &R) {
1091 if (!PreferredSelector.
isNull())
1092 if (
const auto *
Method = dyn_cast<ObjCMethodDecl>(
R.Declaration))
1093 if (PreferredSelector ==
Method->getSelector())
1098 if (!PreferredType.
isNull()) {
1108 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
1118 Context.DeclarationNames.getCXXConstructorName(RecordTy);
1119 return Record->lookup(ConstructorName);
1122void ResultBuilder::MaybeAddConstructorResults(
Result R) {
1123 if (!SemaRef.
getLangOpts().CPlusPlus || !
R.Declaration ||
1130 Record = ClassTemplate->getTemplatedDecl();
1131 else if ((
Record = dyn_cast<CXXRecordDecl>(D))) {
1145 R.Declaration = Ctor;
1147 Results.push_back(R);
1152 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
1153 ND = Tmpl->getTemplatedDecl();
1158 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
1160 if (
R.Kind != Result::RK_Declaration) {
1162 Results.push_back(R);
1167 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(
R.Declaration)) {
1169 getBasePriority(
Using->getTargetDecl()),
1173 std::move(
R.FixIts));
1175 MaybeAddResult(
Result, CurContext);
1179 const Decl *CanonDecl =
R.Declaration->getCanonicalDecl();
1182 bool AsNestedNameSpecifier =
false;
1183 if (!isInterestingDecl(
R.Declaration, AsNestedNameSpecifier))
1190 ShadowMap &SMap = ShadowMaps.back();
1191 ShadowMapEntry::iterator I, IEnd;
1192 ShadowMap::iterator NamePos = SMap.find(
R.Declaration->getDeclName());
1193 if (NamePos != SMap.end()) {
1194 I = NamePos->second.begin();
1195 IEnd = NamePos->second.end();
1198 for (; I != IEnd; ++I) {
1200 unsigned Index = I->second;
1203 Results[Index].Declaration =
R.Declaration;
1213 std::list<ShadowMap>::iterator SM, SMEnd = ShadowMaps.end();
1215 for (SM = ShadowMaps.begin(); SM != SMEnd; ++SM) {
1216 ShadowMapEntry::iterator I, IEnd;
1217 ShadowMap::iterator NamePos = SM->find(
R.Declaration->getDeclName());
1218 if (NamePos != SM->end()) {
1219 I = NamePos->second.begin();
1220 IEnd = NamePos->second.end();
1222 for (; I != IEnd; ++I) {
1224 if (I->first->hasTagIdentifierNamespace() &&
1232 I->first->getIdentifierNamespace() != IDNS)
1236 if (CheckHiddenResult(R, CurContext, I->first))
1244 if (!AllDeclsFound.insert(CanonDecl).second)
1249 if (AsNestedNameSpecifier) {
1250 R.StartsNestedNameSpecifier =
true;
1253 AdjustResultPriorityForDecl(R);
1256 if (
R.QualifierIsInformative && !
R.Qualifier &&
1257 !
R.StartsNestedNameSpecifier) {
1258 const DeclContext *Ctx =
R.Declaration->getDeclContext();
1259 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1262 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1266 std::nullopt, Tag,
false)
1269 R.QualifierIsInformative =
false;
1274 SMap[
R.Declaration->getDeclName()].Add(
R.Declaration, Results.size());
1275 Results.push_back(R);
1277 if (!AsNestedNameSpecifier)
1278 MaybeAddConstructorResults(R);
1283 R.InBaseClass =
true;
1304 for (
unsigned I = 0, E = Candidate.
getNumParams(); I != E; ++I)
1305 if (Candidate.
parameters()[I]->getType().getCanonicalType() !=
1306 Incumbent.
parameters()[I]->getType().getCanonicalType())
1315 if (CandidateRef != IncumbentRef) {
1331 if (CandidateSuperset == IncumbentSuperset)
1343 const auto *CurrentClassScope = [&]() ->
const CXXRecordDecl * {
1345 const auto *CtxMethod = llvm::dyn_cast<CXXMethodDecl>(Ctx);
1346 if (CtxMethod && !CtxMethod->getParent()->isLambda()) {
1347 return CtxMethod->getParent();
1354 bool FunctionCanBeCall =
1355 CurrentClassScope &&
1356 (CurrentClassScope ==
Method->getParent() ||
1357 CurrentClassScope->isDerivedFrom(
Method->getParent()));
1360 if (FunctionCanBeCall)
1365 BaseExprType.
isNull() ?
nullptr
1367 auto *MaybeBase =
Method->getParent();
1369 MaybeDerived == MaybeBase || MaybeDerived->isDerivedFrom(MaybeBase);
1372 return FunctionCanBeCall;
1375bool ResultBuilder::canFunctionBeCalled(
const NamedDecl *ND,
1386 if (
const auto *FuncTmpl = dyn_cast<FunctionTemplateDecl>(ND)) {
1387 ND = FuncTmpl->getTemplatedDecl();
1389 const auto *
Method = dyn_cast<CXXMethodDecl>(ND);
1391 return canCxxMethodBeCalled(
Method, BaseExprType);
1398 NamedDecl *Hiding,
bool InBaseClass =
false,
1400 bool IsInDeclarationContext =
false,
1401 bool IsAddressOfOperand =
false) {
1402 if (
R.Kind != Result::RK_Declaration) {
1404 Results.push_back(R);
1409 if (
const auto *Using = dyn_cast<UsingShadowDecl>(
R.Declaration)) {
1411 getBasePriority(
Using->getTargetDecl()),
1415 std::move(
R.FixIts));
1417 AddResult(
Result, CurContext, Hiding,
false,
1422 bool AsNestedNameSpecifier =
false;
1423 if (!isInterestingDecl(
R.Declaration, AsNestedNameSpecifier))
1430 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
1434 if (!AllDeclsFound.insert(
R.Declaration->getCanonicalDecl()).second)
1439 if (AsNestedNameSpecifier) {
1440 R.StartsNestedNameSpecifier =
true;
1442 }
else if (Filter == &ResultBuilder::IsMember && !
R.Qualifier &&
1445 R.Declaration->getDeclContext()->getRedeclContext()))
1446 R.QualifierIsInformative =
true;
1449 if (
R.QualifierIsInformative && !
R.Qualifier &&
1450 !
R.StartsNestedNameSpecifier) {
1451 const DeclContext *Ctx =
R.Declaration->getDeclContext();
1452 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1455 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1459 std::nullopt, Tag,
false)
1462 R.QualifierIsInformative =
false;
1469 AdjustResultPriorityForDecl(R);
1472 const auto GetQualifiers = [&](
const CXXMethodDecl *MethodDecl) {
1473 if (MethodDecl->isExplicitObjectMemberFunction())
1474 return MethodDecl->getFunctionObjectParameterType().getQualifiers();
1476 return MethodDecl->getMethodQualifiers();
1479 if (IsExplicitObjectMemberFunction &&
1488 if (HasObjectTypeQualifiers)
1489 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(
R.Declaration))
1490 if (
Method->isInstance()) {
1492 if (ObjectTypeQualifiers == MethodQuals)
1494 else if (ObjectTypeQualifiers - MethodQuals) {
1500 switch (
Method->getRefQualifier()) {
1517 CurContext,
Method->getDeclName().getAsOpaqueInteger())];
1519 Result &Incumbent = Results[Entry.second];
1522 ObjectTypeQualifiers, ObjectKind,
1528 Incumbent = std::move(R);
1539 R.DeclaringEntity = IsInDeclarationContext;
1540 R.FunctionCanBeCall =
1541 canFunctionBeCalled(
R.getDeclaration(), BaseExprType) &&
1545 !IsAddressOfOperand;
1548 Results.push_back(R);
1550 if (!AsNestedNameSpecifier)
1551 MaybeAddConstructorResults(R);
1554void ResultBuilder::AddResult(
Result R) {
1555 assert(
R.Kind != Result::RK_Declaration &&
1556 "Declaration results need more context");
1557 Results.push_back(R);
1561void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1564void ResultBuilder::ExitScope() {
1565 ShadowMaps.pop_back();
1570bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1588bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1595 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1596 if (!
ID->getDefinition())
1611bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1612 if (!IsOrdinaryNonTypeName(ND))
1616 if (VD->getType()->isIntegralOrEnumerationType())
1624bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1637bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1639 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1640 ND = ClassTemplate->getTemplatedDecl();
1646bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1651bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1653 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1654 ND = ClassTemplate->getTemplatedDecl();
1657 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1666bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1668 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1669 ND = ClassTemplate->getTemplatedDecl();
1671 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1678bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1684bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1689bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1697bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1705bool ResultBuilder::IsOffsetofField(
const NamedDecl *ND)
const {
1707 if (
const auto *FD = dyn_cast<FieldDecl>(ND))
1708 return !FD->isBitField();
1709 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(ND))
1710 return !IFD->getAnonField()->isBitField();
1715 T =
C.getCanonicalType(
T);
1716 switch (
T->getTypeClass()) {
1717 case Type::ObjCObject:
1718 case Type::ObjCInterface:
1719 case Type::ObjCObjectPointer:
1724 case BuiltinType::ObjCId:
1725 case BuiltinType::ObjCClass:
1726 case BuiltinType::ObjCSel:
1738 if (!
C.getLangOpts().CPlusPlus)
1744 return T->isDependentType() ||
T->isRecordType();
1747bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1757bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1759 if (IsObjCMessageReceiver(ND))
1762 const auto *Var = dyn_cast<VarDecl>(ND);
1766 return Var->hasLocalStorage() && !Var->hasAttr<BlocksAttr>();
1769bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1770 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1771 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1780 return T->isObjCObjectType() ||
T->isObjCObjectPointerType() ||
1781 T->isObjCIdType() ||
1785bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1791bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1800 ResultBuilder &Results;
1801 DeclContext *InitialLookupCtx;
1804 CXXRecordDecl *NamingClass;
1806 std::vector<FixItHint> FixIts;
1807 bool IsInDeclarationContext;
1809 bool IsAddressOfOperand;
1812 CodeCompletionDeclConsumer(
1813 ResultBuilder &Results, DeclContext *InitialLookupCtx,
1814 QualType BaseType = QualType(),
1815 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1816 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1817 FixIts(std::move(FixIts)), IsInDeclarationContext(
false),
1818 IsAddressOfOperand(
false) {
1819 NamingClass = llvm::dyn_cast<CXXRecordDecl>(InitialLookupCtx);
1822 auto ThisType = Results.getSema().getCurrentThisType();
1823 if (!ThisType.isNull()) {
1824 assert(ThisType->isPointerType());
1830 this->BaseType = BaseType;
1833 void setIsInDeclarationContext(
bool IsInDeclarationContext) {
1834 this->IsInDeclarationContext = IsInDeclarationContext;
1837 void setIsAddressOfOperand(
bool IsAddressOfOperand) {
1838 this->IsAddressOfOperand = IsAddressOfOperand;
1841 void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
1842 bool InBaseClass)
override {
1843 ResultBuilder::Result
Result(ND, Results.getBasePriority(ND),
1847 Results.AddResult(
Result, InitialLookupCtx, Hiding, InBaseClass, BaseType,
1848 IsInDeclarationContext, IsAddressOfOperand);
1851 void EnteredContext(DeclContext *Ctx)
override {
1852 Results.addVisitedContext(Ctx);
1861 auto *NamingClass = this->NamingClass;
1862 QualType BaseType = this->BaseType;
1863 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1872 BaseType = QualType();
1878 NamingClass =
nullptr;
1879 BaseType = QualType();
1881 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1888 ResultBuilder &Results) {
1915 Results.getCodeCompletionTUInfo());
1916 if (LangOpts.CPlusPlus) {
1924 Builder.AddTypedTextChunk(
"typename");
1926 Builder.AddPlaceholderChunk(
"name");
1927 Results.AddResult(
Result(Builder.TakeString()));
1929 if (LangOpts.CPlusPlus11) {
1934 Builder.AddTypedTextChunk(
"decltype");
1936 Builder.AddPlaceholderChunk(
"expression");
1938 Results.AddResult(
Result(Builder.TakeString()));
1941 if (LangOpts.Char8 || LangOpts.CPlusPlus20)
1947 if (LangOpts.GNUKeywords) {
1953 Builder.AddTypedTextChunk(
"typeof");
1955 Builder.AddPlaceholderChunk(
"expression");
1956 Results.AddResult(
Result(Builder.TakeString()));
1958 Builder.AddTypedTextChunk(
"typeof");
1960 Builder.AddPlaceholderChunk(
"type");
1962 Results.AddResult(
Result(Builder.TakeString()));
1973 const LangOptions &LangOpts, ResultBuilder &Results) {
1978 Results.AddResult(
Result(
"extern"));
1979 Results.AddResult(
Result(
"static"));
1981 if (LangOpts.CPlusPlus11) {
1986 Builder.AddTypedTextChunk(
"alignas");
1988 Builder.AddPlaceholderChunk(
"expression");
1990 Results.AddResult(
Result(Builder.TakeString()));
1992 Results.AddResult(
Result(
"constexpr"));
1993 Results.AddResult(
Result(
"thread_local"));
1996 if (LangOpts.CPlusPlus20)
1997 Results.AddResult(
Result(
"constinit"));
2002 const LangOptions &LangOpts, ResultBuilder &Results) {
2007 if (LangOpts.CPlusPlus) {
2008 Results.AddResult(
Result(
"explicit"));
2009 Results.AddResult(
Result(
"friend"));
2010 Results.AddResult(
Result(
"mutable"));
2011 Results.AddResult(
Result(
"virtual"));
2019 if (LangOpts.CPlusPlus || LangOpts.C99)
2020 Results.AddResult(
Result(
"inline"));
2022 if (LangOpts.CPlusPlus20)
2023 Results.AddResult(
Result(
"consteval"));
2043 ResultBuilder &Results,
bool NeedAt);
2045 ResultBuilder &Results,
bool NeedAt);
2047 ResultBuilder &Results,
bool NeedAt);
2052 Results.getCodeCompletionTUInfo());
2053 Builder.AddTypedTextChunk(
"typedef");
2055 Builder.AddPlaceholderChunk(
"type");
2057 Builder.AddPlaceholderChunk(
"name");
2064 ResultBuilder &Results) {
2065 Builder.AddTypedTextChunk(
"using");
2067 Builder.AddPlaceholderChunk(
"name");
2069 Builder.AddPlaceholderChunk(
"type");
2092 return LangOpts.CPlusPlus;
2099 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
2102 llvm_unreachable(
"Invalid ParserCompletionContext!");
2112 Policy.CleanUglifiedParameters =
true;
2130 if (!
T.getLocalQualifiers()) {
2133 return BT->getNameAsCString(Policy);
2136 if (
const TagType *TagT = dyn_cast<TagType>(
T))
2137 if (
TagDecl *Tag = TagT->getDecl())
2138 if (!Tag->hasNameForLinkage()) {
2139 switch (Tag->getTagKind()) {
2141 return "struct <anonymous>";
2143 return "__interface <anonymous>";
2145 return "class <anonymous>";
2147 return "union <anonymous>";
2149 return "enum <anonymous>";
2156 T.getAsStringInternal(
Result, Policy);
2169 Builder.AddResultTypeChunk(
2171 Builder.AddTypedTextChunk(
"this");
2176 ResultBuilder &Results,
2178 if (!LangOpts.CPlusPlus11)
2181 Builder.AddTypedTextChunk(
"static_assert");
2183 Builder.AddPlaceholderChunk(
"expression");
2185 Builder.AddPlaceholderChunk(
"message");
2194 Sema &S = Results.getSema();
2195 const auto *CR = llvm::dyn_cast<CXXRecordDecl>(S.
CurContext);
2201 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
2202 for (
auto *Method : CR->methods()) {
2203 if (!Method->isVirtual() || !Method->getIdentifier())
2205 Overrides[Method->getName()].push_back(Method);
2208 for (
const auto &
Base : CR->bases()) {
2209 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
2212 for (
auto *Method : BR->methods()) {
2213 if (!Method->isVirtual() || !Method->getIdentifier())
2215 const auto it = Overrides.find(Method->getName());
2216 bool IsOverriden =
false;
2217 if (it != Overrides.end()) {
2218 for (
auto *MD : it->second) {
2236 false, CCContext, Policy);
2246 Scope *S,
Sema &SemaRef, ResultBuilder &Results) {
2254 if (Results.includeCodePatterns()) {
2256 Builder.AddTypedTextChunk(
"namespace");
2258 Builder.AddPlaceholderChunk(
"identifier");
2262 Builder.AddPlaceholderChunk(
"declarations");
2265 Results.AddResult(
Result(Builder.TakeString()));
2269 Builder.AddTypedTextChunk(
"namespace");
2271 Builder.AddPlaceholderChunk(
"name");
2273 Builder.AddPlaceholderChunk(
"namespace");
2275 Results.AddResult(
Result(Builder.TakeString()));
2278 Builder.AddTypedTextChunk(
"using namespace");
2280 Builder.AddPlaceholderChunk(
"identifier");
2282 Results.AddResult(
Result(Builder.TakeString()));
2285 Builder.AddTypedTextChunk(
"asm");
2287 Builder.AddPlaceholderChunk(
"string-literal");
2289 Results.AddResult(
Result(Builder.TakeString()));
2291 if (Results.includeCodePatterns()) {
2293 Builder.AddTypedTextChunk(
"template");
2295 Builder.AddPlaceholderChunk(
"declaration");
2296 Results.AddResult(
Result(Builder.TakeString()));
2307 if (!CurrentModule) {
2309 Builder.AddTypedTextChunk(
"module");
2312 Results.AddResult(
Result(Builder.TakeString()));
2317 if (!CurrentModule ||
2322 Builder.AddTypedTextChunk(
"module");
2324 Builder.AddPlaceholderChunk(
"name");
2327 Results.AddResult(
Result(Builder.TakeString()));
2332 if (!CurrentModule ||
2336 Builder.AddTypedTextChunk(
"import");
2338 Builder.AddPlaceholderChunk(
"name");
2341 Results.AddResult(
Result(Builder.TakeString()));
2344 if (CurrentModule &&
2348 Builder.AddTypedTextChunk(
"module");
2351 Builder.AddTypedTextChunk(
"private");
2354 Results.AddResult(
Result(Builder.TakeString()));
2359 if (!CurrentModule ||
2374 Builder.AddTypedTextChunk(
"using");
2376 Builder.AddPlaceholderChunk(
"qualifier");
2377 Builder.AddTextChunk(
"::");
2378 Builder.AddPlaceholderChunk(
"name");
2380 Results.AddResult(
Result(Builder.TakeString()));
2387 Builder.AddTypedTextChunk(
"using typename");
2389 Builder.AddPlaceholderChunk(
"qualifier");
2390 Builder.AddTextChunk(
"::");
2391 Builder.AddPlaceholderChunk(
"name");
2393 Results.AddResult(
Result(Builder.TakeString()));
2403 Builder.AddTypedTextChunk(
"public");
2404 if (IsNotInheritanceScope && Results.includeCodePatterns())
2406 Results.AddResult(
Result(Builder.TakeString()));
2409 Builder.AddTypedTextChunk(
"protected");
2410 if (IsNotInheritanceScope && Results.includeCodePatterns())
2412 Results.AddResult(
Result(Builder.TakeString()));
2415 Builder.AddTypedTextChunk(
"private");
2416 if (IsNotInheritanceScope && Results.includeCodePatterns())
2418 Results.AddResult(
Result(Builder.TakeString()));
2436 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
2438 Builder.AddTypedTextChunk(
"template");
2440 Builder.AddPlaceholderChunk(
"parameters");
2442 Results.AddResult(
Result(Builder.TakeString()));
2480 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
2482 Builder.AddTypedTextChunk(
"try");
2486 Builder.AddPlaceholderChunk(
"statements");
2490 Builder.AddTextChunk(
"catch");
2493 Builder.AddPlaceholderChunk(
"declaration");
2498 Builder.AddPlaceholderChunk(
"statements");
2501 Results.AddResult(
Result(Builder.TakeString()));
2506 if (Results.includeCodePatterns()) {
2508 Builder.AddTypedTextChunk(
"if");
2512 Builder.AddPlaceholderChunk(
"condition");
2514 Builder.AddPlaceholderChunk(
"expression");
2519 Builder.AddPlaceholderChunk(
"statements");
2522 Results.AddResult(
Result(Builder.TakeString()));
2525 Builder.AddTypedTextChunk(
"switch");
2529 Builder.AddPlaceholderChunk(
"condition");
2531 Builder.AddPlaceholderChunk(
"expression");
2536 Builder.AddPlaceholderChunk(
"cases");
2539 Results.AddResult(
Result(Builder.TakeString()));
2546 Builder.AddTypedTextChunk(
"case");
2548 Builder.AddPlaceholderChunk(
"expression");
2550 Results.AddResult(
Result(Builder.TakeString()));
2553 Builder.AddTypedTextChunk(
"default");
2555 Results.AddResult(
Result(Builder.TakeString()));
2558 if (Results.includeCodePatterns()) {
2560 Builder.AddTypedTextChunk(
"while");
2564 Builder.AddPlaceholderChunk(
"condition");
2566 Builder.AddPlaceholderChunk(
"expression");
2571 Builder.AddPlaceholderChunk(
"statements");
2574 Results.AddResult(
Result(Builder.TakeString()));
2577 Builder.AddTypedTextChunk(
"do");
2581 Builder.AddPlaceholderChunk(
"statements");
2584 Builder.AddTextChunk(
"while");
2587 Builder.AddPlaceholderChunk(
"expression");
2589 Results.AddResult(
Result(Builder.TakeString()));
2592 Builder.AddTypedTextChunk(
"for");
2596 Builder.AddPlaceholderChunk(
"init-statement");
2598 Builder.AddPlaceholderChunk(
"init-expression");
2601 Builder.AddPlaceholderChunk(
"condition");
2604 Builder.AddPlaceholderChunk(
"inc-expression");
2609 Builder.AddPlaceholderChunk(
"statements");
2612 Results.AddResult(
Result(Builder.TakeString()));
2616 Builder.AddTypedTextChunk(
"for");
2619 Builder.AddPlaceholderChunk(
"range-declaration");
2622 Builder.AddTextChunk(
"in");
2626 Builder.AddPlaceholderChunk(
"range-expression");
2631 Builder.AddPlaceholderChunk(
"statements");
2634 Results.AddResult(
Result(Builder.TakeString()));
2640 Builder.AddTypedTextChunk(
"continue");
2642 Results.AddResult(
Result(Builder.TakeString()));
2647 Builder.AddTypedTextChunk(
"break");
2649 Results.AddResult(
Result(Builder.TakeString()));
2654 if (
const auto *Function = dyn_cast<FunctionDecl>(SemaRef.
CurContext)) {
2655 if (!Function->getType().isNull())
2656 ReturnType = Function->getReturnType();
2657 }
else if (
const auto *Method =
2658 dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
2659 ReturnType = Method->getReturnType();
2664 Builder.AddTypedTextChunk(
"return");
2666 Results.AddResult(
Result(Builder.TakeString()));
2668 assert(!ReturnType.
isNull());
2670 Builder.AddTypedTextChunk(
"return");
2672 Builder.AddPlaceholderChunk(
"expression");
2674 Results.AddResult(
Result(Builder.TakeString()));
2677 Builder.AddTypedTextChunk(
"co_return");
2679 Builder.AddPlaceholderChunk(
"expression");
2681 Results.AddResult(
Result(Builder.TakeString()));
2685 Builder.AddTypedTextChunk(
"return true");
2687 Results.AddResult(
Result(Builder.TakeString()));
2689 Builder.AddTypedTextChunk(
"return false");
2691 Results.AddResult(
Result(Builder.TakeString()));
2696 Builder.AddTypedTextChunk(
"return nullptr");
2698 Results.AddResult(
Result(Builder.TakeString()));
2703 Builder.AddTypedTextChunk(
"goto");
2705 Builder.AddPlaceholderChunk(
"label");
2707 Results.AddResult(
Result(Builder.TakeString()));
2710 Builder.AddTypedTextChunk(
"using namespace");
2712 Builder.AddPlaceholderChunk(
"identifier");
2714 Results.AddResult(
Result(Builder.TakeString()));
2731 Builder.AddTypedTextChunk(
"__bridge");
2733 Builder.AddPlaceholderChunk(
"type");
2735 Builder.AddPlaceholderChunk(
"expression");
2736 Results.AddResult(
Result(Builder.TakeString()));
2739 Builder.AddTypedTextChunk(
"__bridge_transfer");
2741 Builder.AddPlaceholderChunk(
"Objective-C type");
2743 Builder.AddPlaceholderChunk(
"expression");
2744 Results.AddResult(
Result(Builder.TakeString()));
2747 Builder.AddTypedTextChunk(
"__bridge_retained");
2749 Builder.AddPlaceholderChunk(
"CF type");
2751 Builder.AddPlaceholderChunk(
"expression");
2752 Results.AddResult(
Result(Builder.TakeString()));
2763 Builder.AddResultTypeChunk(
"bool");
2764 Builder.AddTypedTextChunk(
"true");
2765 Results.AddResult(
Result(Builder.TakeString()));
2768 Builder.AddResultTypeChunk(
"bool");
2769 Builder.AddTypedTextChunk(
"false");
2770 Results.AddResult(
Result(Builder.TakeString()));
2774 Builder.AddTypedTextChunk(
"dynamic_cast");
2776 Builder.AddPlaceholderChunk(
"type");
2779 Builder.AddPlaceholderChunk(
"expression");
2781 Results.AddResult(
Result(Builder.TakeString()));
2785 Builder.AddTypedTextChunk(
"static_cast");
2787 Builder.AddPlaceholderChunk(
"type");
2790 Builder.AddPlaceholderChunk(
"expression");
2792 Results.AddResult(
Result(Builder.TakeString()));
2795 Builder.AddTypedTextChunk(
"reinterpret_cast");
2797 Builder.AddPlaceholderChunk(
"type");
2800 Builder.AddPlaceholderChunk(
"expression");
2802 Results.AddResult(
Result(Builder.TakeString()));
2805 Builder.AddTypedTextChunk(
"const_cast");
2807 Builder.AddPlaceholderChunk(
"type");
2810 Builder.AddPlaceholderChunk(
"expression");
2812 Results.AddResult(
Result(Builder.TakeString()));
2816 Builder.AddResultTypeChunk(
"std::type_info");
2817 Builder.AddTypedTextChunk(
"typeid");
2819 Builder.AddPlaceholderChunk(
"expression-or-type");
2821 Results.AddResult(
Result(Builder.TakeString()));
2825 Builder.AddTypedTextChunk(
"new");
2827 Builder.AddPlaceholderChunk(
"type");
2829 Builder.AddPlaceholderChunk(
"expressions");
2831 Results.AddResult(
Result(Builder.TakeString()));
2834 Builder.AddTypedTextChunk(
"new");
2836 Builder.AddPlaceholderChunk(
"type");
2838 Builder.AddPlaceholderChunk(
"size");
2841 Builder.AddPlaceholderChunk(
"expressions");
2843 Results.AddResult(
Result(Builder.TakeString()));
2846 Builder.AddResultTypeChunk(
"void");
2847 Builder.AddTypedTextChunk(
"delete");
2849 Builder.AddPlaceholderChunk(
"expression");
2850 Results.AddResult(
Result(Builder.TakeString()));
2853 Builder.AddResultTypeChunk(
"void");
2854 Builder.AddTypedTextChunk(
"delete");
2859 Builder.AddPlaceholderChunk(
"expression");
2860 Results.AddResult(
Result(Builder.TakeString()));
2864 Builder.AddResultTypeChunk(
"void");
2865 Builder.AddTypedTextChunk(
"throw");
2867 Builder.AddPlaceholderChunk(
"expression");
2868 Results.AddResult(
Result(Builder.TakeString()));
2875 Builder.AddResultTypeChunk(
"std::nullptr_t");
2876 Builder.AddTypedTextChunk(
"nullptr");
2877 Results.AddResult(
Result(Builder.TakeString()));
2880 Builder.AddResultTypeChunk(
"size_t");
2881 Builder.AddTypedTextChunk(
"alignof");
2883 Builder.AddPlaceholderChunk(
"type");
2885 Results.AddResult(
Result(Builder.TakeString()));
2888 Builder.AddResultTypeChunk(
"bool");
2889 Builder.AddTypedTextChunk(
"noexcept");
2891 Builder.AddPlaceholderChunk(
"expression");
2893 Results.AddResult(
Result(Builder.TakeString()));
2896 Builder.AddResultTypeChunk(
"size_t");
2897 Builder.AddTypedTextChunk(
"sizeof...");
2899 Builder.AddPlaceholderChunk(
"parameter-pack");
2901 Results.AddResult(
Result(Builder.TakeString()));
2906 Builder.AddTypedTextChunk(
"co_await");
2908 Builder.AddPlaceholderChunk(
"expression");
2909 Results.AddResult(
Result(Builder.TakeString()));
2912 Builder.AddTypedTextChunk(
"co_yield");
2914 Builder.AddPlaceholderChunk(
"expression");
2915 Results.AddResult(
Result(Builder.TakeString()));
2918 Builder.AddResultTypeChunk(
"bool");
2919 Builder.AddTypedTextChunk(
"requires");
2922 Builder.AddPlaceholderChunk(
"parameters");
2927 Builder.AddPlaceholderChunk(
"requirements");
2930 Results.AddResult(
Result(Builder.TakeString()));
2934 Builder.AddTypedTextChunk(
"requires");
2936 Builder.AddPlaceholderChunk(
"expression");
2938 Results.AddResult(
Result(Builder.TakeString()));
2948 if (ID->getSuperClass()) {
2949 std::string SuperType;
2950 SuperType = ID->getSuperClass()->getNameAsString();
2951 if (Method->isInstanceMethod())
2954 Builder.AddResultTypeChunk(Allocator.
CopyString(SuperType));
2955 Builder.AddTypedTextChunk(
"super");
2956 Results.AddResult(
Result(Builder.TakeString()));
2965 Builder.AddResultTypeChunk(
"size_t");
2967 Builder.AddTypedTextChunk(
"alignof");
2969 Builder.AddTypedTextChunk(
"_Alignof");
2971 Builder.AddPlaceholderChunk(
"type");
2973 Results.AddResult(
Result(Builder.TakeString()));
2978 Builder.AddResultTypeChunk(
"nullptr_t");
2979 Builder.AddTypedTextChunk(
"nullptr");
2980 Results.AddResult(
Result(Builder.TakeString()));
2984 Builder.AddResultTypeChunk(
"size_t");
2985 Builder.AddTypedTextChunk(
"sizeof");
2987 Builder.AddPlaceholderChunk(
"expression-or-type");
2989 Results.AddResult(
Result(Builder.TakeString()));
3002 Results.AddResult(
Result(
"operator"));
3022 T = Function->getReturnType();
3023 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3024 if (!BaseType.isNull())
3025 T = Method->getSendResultType(BaseType);
3027 T = Method->getReturnType();
3028 }
else if (
const auto *
Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
3029 T = Context.getCanonicalTagType(
3033 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
3034 if (!BaseType.isNull())
3035 T = Ivar->getUsageType(BaseType);
3037 T = Ivar->getType();
3038 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
3040 }
else if (
const auto *Property = dyn_cast<ObjCPropertyDecl>(ND)) {
3041 if (!BaseType.isNull())
3042 T = Property->getUsageType(BaseType);
3044 T = Property->getType();
3047 if (
T.isNull() || Context.hasSameType(
T, Context.DependentTy))
3050 Result.AddResultTypeChunk(
3057 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
3058 if (Sentinel->getSentinel() == 0) {
3060 Result.AddTextChunk(
", nil");
3062 Result.AddTextChunk(
", NULL");
3064 Result.AddTextChunk(
", (void*)0");
3084 if (
auto nullability = AttributedType::stripOuterNullability(
Type)) {
3085 switch (*nullability) {
3095 Result +=
"null_unspecified ";
3099 llvm_unreachable(
"Not supported as a context-sensitive keyword!");
3116 bool SuppressBlock =
false) {
3122 if (!SuppressBlock) {
3125 TypedefTL.getDecl()->getTypeSourceInfo()) {
3138 TL = AttrTL.getModifiedLoc();
3157 bool SuppressBlockName =
false,
bool SuppressBlock =
false,
3162 bool SuppressName =
false,
bool SuppressBlock =
false,
3170 if (
const auto *PVD = dyn_cast<ParmVarDecl>(Param))
3171 ObjCQual = PVD->getObjCDeclQualifier();
3173 if (Param->getType()->isDependentType() ||
3174 !Param->getType()->isBlockPointerType()) {
3179 if (Param->getIdentifier() && !ObjCMethodParam && !SuppressName)
3180 Result = std::string(Param->getIdentifier()->deuglifiedName());
3184 Type =
Type.substObjCTypeArgs(Param->getASTContext(), *ObjCSubsts,
3186 if (ObjCMethodParam) {
3189 if (Param->getIdentifier() && !SuppressName)
3190 Result += Param->getIdentifier()->deuglifiedName();
3205 if (!
Block && ObjCMethodParam &&
3208 ->findPropertyDecl(
false))
3217 if (!ObjCMethodParam && Param->getIdentifier())
3218 Result = std::string(Param->getIdentifier()->deuglifiedName());
3222 if (ObjCMethodParam) {
3227 if (
Result.back() !=
')')
3229 if (Param->getIdentifier())
3230 Result += Param->getIdentifier()->deuglifiedName();
3241 false, SuppressBlock,
3257 bool SuppressBlockName,
bool SuppressBlock,
3265 if (!ResultType->
isVoidType() || SuppressBlock)
3270 if (!BlockProto ||
Block.getNumParams() == 0) {
3277 for (
unsigned I = 0, N =
Block.getNumParams(); I != N; ++I) {
3290 if (SuppressBlock) {
3293 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3302 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3312 const SourceRange SrcRange = Param->getDefaultArgRange();
3322 if (srcText.empty() || srcText ==
"=") {
3328 std::string DefValue(srcText.str());
3331 if (DefValue.at(0) !=
'=') {
3335 return " = " + DefValue;
3337 return " " + DefValue;
3344 unsigned Start = 0,
bool InOptional =
false,
bool FunctionCanBeCall =
true,
3345 bool IsInDeclarationContext =
false) {
3346 bool FirstParameter =
true;
3347 bool AsInformativeChunk = !(FunctionCanBeCall || IsInDeclarationContext);
3349 const FunctionDecl *BetterSignatureDecl = BetterSignature(Function, Start);
3351 for (
unsigned P = Start, N = Function->getNumParams(); P != N; ++P) {
3354 if (Param->hasDefaultArg() && !InOptional && !IsInDeclarationContext &&
3355 !AsInformativeChunk) {
3359 Result.getCodeCompletionTUInfo());
3360 if (!FirstParameter)
3370 if (FirstParameter && Param->isExplicitObjectParameter()) {
3375 FirstParameter =
false;
3377 if (AsInformativeChunk)
3378 Result.AddInformativeChunk(
", ");
3387 std::string DefaultValue;
3388 if (Param->hasDefaultArg()) {
3389 if (IsInDeclarationContext)
3397 if (Function->isVariadic() && P == N - 1)
3398 PlaceholderStr +=
", ...";
3401 if (AsInformativeChunk)
3402 Result.AddInformativeChunk(
3403 Result.getAllocator().CopyString(PlaceholderStr));
3404 else if (IsInDeclarationContext) {
3405 Result.AddTextChunk(
Result.getAllocator().CopyString(PlaceholderStr));
3406 if (DefaultValue.length() != 0)
3407 Result.AddInformativeChunk(
3408 Result.getAllocator().CopyString(DefaultValue));
3410 Result.AddPlaceholderChunk(
3411 Result.getAllocator().CopyString(PlaceholderStr));
3415 if (Proto->isVariadic()) {
3416 if (Proto->getNumParams() == 0)
3417 Result.AddPlaceholderChunk(
"...");
3427 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false,
3428 bool AsInformativeChunk =
false) {
3429 bool FirstParameter =
true;
3438 PEnd = Params->
begin() + MaxParameters;
3441 bool HasDefaultArg =
false;
3442 std::string PlaceholderStr;
3444 if (TTP->wasDeclaredWithTypename())
3445 PlaceholderStr =
"typename";
3446 else if (
const auto *TC = TTP->getTypeConstraint()) {
3447 llvm::raw_string_ostream OS(PlaceholderStr);
3448 TC->print(OS, Policy);
3450 PlaceholderStr =
"class";
3452 if (TTP->getIdentifier()) {
3453 PlaceholderStr +=
' ';
3454 PlaceholderStr += TTP->getIdentifier()->deuglifiedName();
3457 HasDefaultArg = TTP->hasDefaultArgument();
3459 dyn_cast<NonTypeTemplateParmDecl>(*P)) {
3460 if (NTTP->getIdentifier())
3461 PlaceholderStr = std::string(NTTP->getIdentifier()->deuglifiedName());
3462 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
3463 HasDefaultArg = NTTP->hasDefaultArgument();
3470 PlaceholderStr =
"template<...> class";
3472 PlaceholderStr +=
' ';
3479 if (HasDefaultArg && !InDefaultArg && !AsInformativeChunk) {
3483 Result.getCodeCompletionTUInfo());
3484 if (!FirstParameter)
3487 P - Params->
begin(),
true);
3492 InDefaultArg =
false;
3495 FirstParameter =
false;
3497 if (AsInformativeChunk)
3498 Result.AddInformativeChunk(
", ");
3503 if (AsInformativeChunk)
3504 Result.AddInformativeChunk(
3505 Result.getAllocator().CopyString(PlaceholderStr));
3507 Result.AddPlaceholderChunk(
3508 Result.getAllocator().CopyString(PlaceholderStr));
3516 bool QualifierIsInformative,
3522 std::string PrintedNNS;
3524 llvm::raw_string_ostream OS(PrintedNNS);
3525 Qualifier.print(OS, Policy);
3527 if (QualifierIsInformative)
3528 Result.AddInformativeChunk(
Result.getAllocator().CopyString(PrintedNNS));
3530 Result.AddTextChunk(
Result.getAllocator().CopyString(PrintedNNS));
3535 bool AsInformativeChunk =
true) {
3540 if (AsInformativeChunk)
3541 Result.AddInformativeChunk(
" const");
3543 Result.AddTextChunk(
" const");
3548 if (AsInformativeChunk)
3549 Result.AddInformativeChunk(
" volatile");
3551 Result.AddTextChunk(
" volatile");
3556 if (AsInformativeChunk)
3557 Result.AddInformativeChunk(
" restrict");
3559 Result.AddTextChunk(
" restrict");
3564 std::string QualsStr;
3566 QualsStr +=
" const";
3568 QualsStr +=
" volatile";
3570 QualsStr +=
" restrict";
3572 if (AsInformativeChunk)
3573 Result.AddInformativeChunk(
Result.getAllocator().CopyString(QualsStr));
3575 Result.AddTextChunk(
Result.getAllocator().CopyString(QualsStr));
3581 bool AsInformativeChunks =
true) {
3582 if (
auto *CxxMethodDecl = llvm::dyn_cast_if_present<CXXMethodDecl>(Function);
3583 CxxMethodDecl && CxxMethodDecl->hasCXXExplicitFunctionObjectParameter()) {
3585 const auto Quals = CxxMethodDecl->getFunctionObjectParameterType();
3586 if (!Quals.hasQualifiers())
3592 if (!Proto || !Proto->getMethodQuals())
3607 switch (ExceptInfo.Type) {
3610 NameAndSignature +=
" noexcept";
3628 const char *OperatorName =
nullptr;
3631 case OO_Conditional:
3633 OperatorName =
"operator";
3636#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
3638 OperatorName = "operator" Spelling; \
3640#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly)
3641#include "clang/Basic/OperatorKinds.def"
3644 OperatorName =
"operator new";
3647 OperatorName =
"operator delete";
3650 OperatorName =
"operator new[]";
3652 case OO_Array_Delete:
3653 OperatorName =
"operator delete[]";
3656 OperatorName =
"operator()";
3659 OperatorName =
"operator[]";
3662 Result.AddTypedTextChunk(OperatorName);
3670 Result.AddTypedTextChunk(
3687 Result.AddTypedTextChunk(
3692 Result.AddTypedTextChunk(
3693 Result.getAllocator().CopyString(
Record->getNameAsString()));
3707 bool IncludeBriefComments) {
3709 CCTUInfo, IncludeBriefComments);
3721 return Result.TakeString();
3732 Result.AddPlaceholderChunk(
"...");
3746 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3751 Result.AddPlaceholderChunk(
3752 Result.getAllocator().CopyString((*A)->getName()));
3755 return Result.TakeString();
3767 bool IncludeBriefComments) {
3783 Result.addBriefComment(RC->getBriefText(Ctx));
3793 return Result.TakeString();
3797 PP, Ctx,
Result, IncludeBriefComments, CCContext, Policy);
3801 std::string &BeforeName,
3802 std::string &NameAndSignature) {
3803 bool SeenTypedChunk =
false;
3804 for (
auto &Chunk : CCS) {
3806 assert(SeenTypedChunk &&
"optional parameter before name");
3813 NameAndSignature += Chunk.Text;
3815 BeforeName += Chunk.Text;
3827 std::string BeforeName;
3828 std::string NameAndSignature;
3834 const auto *VirtualFunc = dyn_cast<FunctionDecl>(
Declaration);
3835 assert(VirtualFunc &&
"overridden decl must be a function");
3838 NameAndSignature +=
" override";
3840 Result.AddTextChunk(
Result.getAllocator().CopyString(BeforeName));
3842 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(NameAndSignature));
3843 return Result.TakeString();
3849 const auto *VD = dyn_cast<VarDecl>(ND);
3852 const auto *
RecordDecl = VD->getType()->getAsCXXRecordDecl();
3865 if (IncludeBriefComments) {
3868 Result.addBriefComment(RC->getBriefText(Ctx));
3873 Result.AddTypedTextChunk(
3875 Result.AddTextChunk(
"::");
3876 return Result.TakeString();
3880 Result.AddAnnotation(
Result.getAllocator().CopyString(I->getAnnotation()));
3888 if (InsertParameters)
3891 Result.AddInformativeChunk(
"(");
3896 if (InsertParameters)
3899 Result.AddInformativeChunk(
")");
3904 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND)) {
3905 AddFunctionTypeAndResult(
Function);
3906 return Result.TakeString();
3909 if (
const auto *CallOperator =
3911 AddFunctionTypeAndResult(CallOperator);
3912 return Result.TakeString();
3918 dyn_cast<FunctionTemplateDecl>(ND)) {
3929 llvm::SmallBitVector
Deduced(FunTmpl->getTemplateParameters()->size());
3934 unsigned LastDeducibleArgument;
3935 for (LastDeducibleArgument =
Deduced.size(); LastDeducibleArgument > 0;
3936 --LastDeducibleArgument) {
3937 if (!
Deduced[LastDeducibleArgument - 1]) {
3941 bool HasDefaultArg =
false;
3942 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3943 LastDeducibleArgument - 1);
3945 HasDefaultArg = TTP->hasDefaultArgument();
3947 dyn_cast<NonTypeTemplateParmDecl>(Param))
3948 HasDefaultArg = NTTP->hasDefaultArgument();
3976 Result.AddInformativeChunk(
"<");
3978 Ctx, Policy, FunTmpl,
Result, LastDeducibleArgument, 0,
3985 Result.AddInformativeChunk(
">");
3990 if (InsertParameters)
3993 Result.AddInformativeChunk(
"(");
3998 if (InsertParameters)
4001 Result.AddInformativeChunk(
")");
4003 return Result.TakeString();
4006 if (
const auto *
Template = dyn_cast<TemplateDecl>(ND)) {
4009 Result.AddTypedTextChunk(
4014 return Result.TakeString();
4017 if (
const auto *
Method = dyn_cast<ObjCMethodDecl>(ND)) {
4020 Result.AddTypedTextChunk(
4022 return Result.TakeString();
4028 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(SelName));
4030 Result.AddInformativeChunk(
Result.getAllocator().CopyString(SelName));
4034 if (
Method->param_size() == 1)
4035 Result.AddTypedTextChunk(
"");
4041 PEnd =
Method->param_end();
4042 P != PEnd && Idx < Sel.
getNumArgs(); (
void)++P, ++Idx) {
4061 QualType ParamType = (*P)->getType();
4062 std::optional<ArrayRef<QualType>> ObjCSubsts;
4078 Arg += II->getName();
4081 if (
Method->isVariadic() && (P + 1) == PEnd)
4085 Result.AddTextChunk(
Result.getAllocator().CopyString(Arg));
4087 Result.AddInformativeChunk(
Result.getAllocator().CopyString(Arg));
4089 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
4092 if (
Method->isVariadic()) {
4093 if (
Method->param_size() == 0) {
4095 Result.AddTextChunk(
", ...");
4097 Result.AddInformativeChunk(
", ...");
4099 Result.AddPlaceholderChunk(
", ...");
4105 return Result.TakeString();
4112 Result.AddTypedTextChunk(
4114 return Result.TakeString();
4125 const auto *M = dyn_cast<ObjCMethodDecl>(ND);
4137 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
4138 if (!M || !M->isPropertyAccessor())
4161 auto FDecl =
Result.getFunction();
4164 if (ArgIndex < FDecl->getNumParams())
4172 unsigned CurrentArg) {
4173 unsigned ChunkIndex = 0;
4174 auto AddChunk = [&](llvm::StringRef Placeholder) {
4177 const char *
Copy =
Result.getAllocator().CopyString(Placeholder);
4178 if (ChunkIndex == CurrentArg)
4186 if (
auto *CRD = llvm::dyn_cast<CXXRecordDecl>(RD)) {
4187 for (
const auto &
Base : CRD->bases())
4188 AddChunk(
Base.getType().getAsString(Policy));
4190 for (
const auto &Field : RD->
fields())
4200 unsigned CurrentArg,
unsigned Start = 0,
bool InOptional =
false) {
4206 bool FirstParameter =
true;
4207 unsigned NumParams =
4208 Function ? Function->getNumParams() :
Prototype->getNumParams();
4210 Function ? BetterSignature(Function, Start) :
nullptr;
4212 for (
unsigned P = Start; P != NumParams; ++P) {
4213 if (Function && Function->getParamDecl(P)->hasDefaultArg() && !InOptional) {
4217 Result.getCodeCompletionTUInfo());
4218 if (!FirstParameter)
4222 PrototypeLoc, Opt, CurrentArg, P,
4231 if (Function && FirstParameter &&
4232 Function->getParamDecl(P)->isExplicitObjectParameter()) {
4237 FirstParameter =
false;
4244 std::string Placeholder;
4245 assert(P < Prototype->getNumParams());
4246 if (Function || PrototypeLoc) {
4250 if (Param->hasDefaultArg())
4252 Context.getLangOpts());
4254 Placeholder =
Prototype->getParamType(P).getAsString(Policy);
4257 if (P == CurrentArg)
4258 Result.AddCurrentParameterChunk(
4259 Result.getAllocator().CopyString(Placeholder));
4261 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Placeholder));
4266 Result.getCodeCompletionTUInfo());
4267 if (!FirstParameter)
4270 if (CurrentArg < NumParams)
4282 if (
const auto *
Type = dyn_cast<TemplateTypeParmDecl>(Param)) {
4284 }
else if (
const auto *
NonType = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4286 }
else if (
const auto *
Template = dyn_cast<TemplateTemplateParmDecl>(Param)) {
4290 llvm::raw_string_ostream OS(
Result);
4291 Param->print(OS, Policy);
4297 if (
const auto *CTD = dyn_cast<ClassTemplateDecl>(TD))
4298 return CTD->getTemplatedDecl()->getKindName().str();
4299 if (
const auto *VTD = dyn_cast<VarTemplateDecl>(TD))
4300 return VTD->getTemplatedDecl()->getType().getAsString(Policy);
4301 if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(TD))
4302 return FTD->getTemplatedDecl()->getReturnType().getAsString(Policy);
4317 Builder.getCodeCompletionTUInfo());
4319 if (!ResultType.empty())
4320 Builder.AddResultTypeChunk(Builder.getAllocator().CopyString(ResultType));
4321 Builder.AddTextChunk(
4327 for (
unsigned I = 0; I < Params.size(); ++I) {
4329 std::string Placeholder =
4332 Current = &OptionalBuilder;
4341 if (Current == &OptionalBuilder)
4347 Builder.AddInformativeChunk(
"()");
4348 return Builder.TakeString();
4355 bool Braced)
const {
4379 if (IncludeBriefComments) {
4386 llvm::raw_string_ostream OS(Name);
4388 Result.AddTextChunk(
Result.getAllocator().CopyString(Name));
4391 Result.AddResultTypeChunk(
Result.getAllocator().CopyString(
4406 return Result.TakeString();
4411 bool PreferredTypeIsPointer) {
4415 if (MacroName ==
"nil" || MacroName ==
"NULL" || MacroName ==
"Nil") {
4417 if (PreferredTypeIsPointer)
4421 else if (MacroName ==
"YES" || MacroName ==
"NO" || MacroName ==
"true" ||
4422 MacroName ==
"false")
4425 else if (MacroName ==
"bool")
4438 case Decl::EnumConstant:
4442 case Decl::Function:
4444 case Decl::ObjCCategory:
4446 case Decl::ObjCCategoryImpl:
4448 case Decl::ObjCImplementation:
4451 case Decl::ObjCInterface:
4453 case Decl::ObjCIvar:
4455 case Decl::ObjCMethod:
4459 case Decl::CXXMethod:
4461 case Decl::CXXConstructor:
4463 case Decl::CXXDestructor:
4465 case Decl::CXXConversion:
4467 case Decl::ObjCProperty:
4469 case Decl::ObjCProtocol:
4475 case Decl::TypeAlias:
4477 case Decl::TypeAliasTemplate:
4481 case Decl::Namespace:
4483 case Decl::NamespaceAlias:
4485 case Decl::TemplateTypeParm:
4487 case Decl::NonTypeTemplateParm:
4489 case Decl::TemplateTemplateParm:
4491 case Decl::FunctionTemplate:
4493 case Decl::ClassTemplate:
4495 case Decl::AccessSpec:
4497 case Decl::ClassTemplatePartialSpecialization:
4499 case Decl::UsingDirective:
4501 case Decl::StaticAssert:
4504 case Decl::FriendTemplate:
4506 case Decl::TranslationUnit:
4510 case Decl::UnresolvedUsingValue:
4511 case Decl::UnresolvedUsingTypename:
4514 case Decl::UsingEnum:
4517 case Decl::ObjCPropertyImpl:
4525 llvm_unreachable(
"Unexpected Kind!");
4530 case Decl::ObjCTypeParam:
4536 case Decl::LinkageSpec:
4540 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
4541 switch (TD->getTagKind()) {
4559 bool LoadExternal,
bool IncludeUndefined,
4560 bool TargetTypeIsPointer =
false) {
4563 Results.EnterNewScope();
4565 for (
const auto &M : PP.
macros(LoadExternal)) {
4567 if (IncludeUndefined || MD) {
4575 TargetTypeIsPointer)));
4579 Results.ExitScope();
4583 ResultBuilder &Results) {
4586 Results.EnterNewScope();
4590 if (LangOpts.C99 || LangOpts.CPlusPlus11)
4592 Results.ExitScope();
4599 unsigned NumResults) {
4604static CodeCompletionContext
4662 llvm_unreachable(
"Invalid ParserCompletionContext!");
4674 ResultBuilder &Results) {
4680 CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(CurContext);
4681 if (!Method || !Method->isVirtual())
4686 for (
auto *P : Method->parameters())
4687 if (!P->getDeclName())
4693 Results.getCodeCompletionTUInfo());
4694 if (Overridden->getCanonicalDecl() == Method->getCanonicalDecl())
4700 S.
Context, CurContext, Overridden->getDeclContext());
4703 llvm::raw_string_ostream OS(Str);
4704 NNS.
print(OS, Policy);
4705 Builder.AddTextChunk(Results.getAllocator().CopyString(Str));
4707 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
4710 Builder.AddTypedTextChunk(
4711 Results.getAllocator().CopyString(Overridden->getNameAsString()));
4713 bool FirstParam =
true;
4714 for (
auto *P : Method->parameters()) {
4720 Builder.AddPlaceholderChunk(
4721 Results.getAllocator().CopyString(P->getIdentifier()->getName()));
4727 Results.Ignore(Overridden);
4737 Results.EnterNewScope();
4745 SemaRef.PP.getHeaderSearchInfo().collectAllModules(Modules);
4752 StringRef CurrentPrimary;
4754 CurrentPrimary = CurrentModule->getPrimaryModuleInterfaceName();
4755 else if (
SemaRef.PP.isInNamedModule())
4756 CurrentPrimary =
SemaRef.PP.getNamedModuleName().split(
':').first;
4757 llvm::StringSet<> AddedModules;
4758 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
4761 if (Modules[I]->isModulePartition()) {
4762 if (CurrentPrimary.empty() ||
4763 Modules[I]->getPrimaryModuleInterfaceName() != CurrentPrimary)
4766 Builder.AddTypedTextChunk(
4767 Builder.getAllocator().CopyString(Modules[I]->Name));
4768 Results.AddResult(
Result(
4772 AddedModules.insert(Modules[I]->Name);
4777 for (
const auto &Entry :
SemaRef.PP.getHeaderSearchInfo()
4778 .getHeaderSearchOpts()
4779 .PrebuiltModuleFiles) {
4780 if (AddedModules.count(Entry.first))
4782 StringRef Name = Entry.first;
4784 if (
auto [Primary, Partition] = Name.split(
':'); !Partition.empty()) {
4785 if (CurrentPrimary.empty() || Primary != CurrentPrimary)
4788 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Name));
4801 Builder.AddTypedTextChunk(
4802 Builder.getAllocator().CopyString(Submodule->Name));
4803 Results.AddResult(
Result(
4810 Results.ExitScope();
4812 Results.getCompletionContext(), Results.data(),
4821 Results.EnterNewScope();
4826 switch (CompletionContext) {
4836 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
4846 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4848 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4859 auto ThisType =
SemaRef.getCurrentThisType();
4860 if (ThisType.isNull()) {
4862 if (
auto *MethodDecl = llvm::dyn_cast_if_present<CXXMethodDecl>(
4863 SemaRef.getCurFunctionDecl()))
4864 Results.setExplicitObjectMemberFn(
4865 MethodDecl->isExplicitObjectMemberFunction());
4869 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
4873 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
4874 SemaRef.LookupVisibleDecls(S,
SemaRef.LookupOrdinaryName, Consumer,
4879 Results.ExitScope();
4881 switch (CompletionContext) {
4909 Results.getCompletionContext(), Results.data(),
4916 bool AtArgumentExpression,
bool IsSuper,
4917 ResultBuilder &Results);
4920 bool AllowNonIdentifiers,
4921 bool AllowNestedNameSpecifiers) {
4923 ResultBuilder Results(
4926 AllowNestedNameSpecifiers
4931 Results.EnterNewScope();
4934 Results.AddResult(
Result(
"const"));
4935 Results.AddResult(
Result(
"volatile"));
4937 Results.AddResult(
Result(
"restrict"));
4943 Results.AddResult(
"final");
4945 if (AllowNonIdentifiers) {
4946 Results.AddResult(
Result(
"operator"));
4950 if (AllowNestedNameSpecifiers) {
4951 Results.allowNestedNameSpecifiers();
4952 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
4953 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
4957 Results.setFilter(
nullptr);
4960 Results.ExitScope();
4966 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
4977 if (!
T.get().isNull() &&
T.get()->isObjCObjectOrInterfaceType())
4985 Results.getCompletionContext(), Results.data(),
4990 if (
Scope ==
"clang")
4998 if (
Scope ==
"_Clang")
5000 if (
Scope ==
"__gnu__")
5024 llvm::StringRef InScopeName;
5025 bool InScopeUnderscore =
false;
5027 InScopeName = InScope->
getName();
5029 InScopeName = NoUnderscore;
5030 InScopeUnderscore =
true;
5037 llvm::DenseSet<llvm::StringRef> FoundScopes;
5039 if (A.IsTargetSpecific &&
5044 for (
const auto &S : A.Spellings) {
5045 if (S.Syntax != Syntax)
5047 llvm::StringRef Name = S.NormalizedFullName;
5048 llvm::StringRef
Scope;
5051 std::tie(
Scope, Name) = Name.split(
"::");
5053 std::swap(Name,
Scope);
5059 if (!
Scope.empty() && FoundScopes.insert(
Scope).second) {
5070 if (!InScopeName.empty()) {
5071 if (
Scope != InScopeName)
5076 auto Add = [&](llvm::StringRef
Scope, llvm::StringRef Name,
5079 Results.getCodeCompletionTUInfo());
5081 if (!
Scope.empty()) {
5090 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
Text));
5092 if (!A.ArgNames.empty()) {
5095 for (
const char *Arg : A.ArgNames) {
5099 Builder.AddPlaceholderChunk(Arg);
5104 Results.AddResult(Builder.TakeString());
5111 if (!InScopeUnderscore)
5112 Add(
Scope, Name,
false);
5117 if (!(InScope && !InScopeUnderscore) && SyntaxSupportsGuards) {
5118 if (
Scope.empty()) {
5119 Add(
Scope, Name,
true);
5124 Add(GuardedScope, Name,
true);
5134 for (
const auto &Entry : ParsedAttrInfoRegistry::entries())
5135 AddCompletions(*Entry.instantiate());
5138 Results.getCompletionContext(), Results.data(),
5157struct CoveredEnumerators {
5165 const CoveredEnumerators &Enumerators) {
5167 if (Context.getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) {
5174 Results.EnterNewScope();
5175 for (
auto *E :
Enum->enumerators()) {
5176 if (Enumerators.Seen.count(E))
5180 Results.AddResult(R, CurContext,
nullptr,
false);
5182 Results.ExitScope();
5188 assert(!
T.isNull());
5201 if (
T->isPointerType())
5202 T =
T->getPointeeType();
5211 if (!Results.includeCodePatterns())
5214 Results.getCodeCompletionTUInfo());
5219 if (!Parameters.empty()) {
5228 constexpr llvm::StringLiteral NamePlaceholder =
"!#!NAME_GOES_HERE!#!";
5229 std::string
Type = std::string(NamePlaceholder);
5231 llvm::StringRef Prefix, Suffix;
5232 std::tie(Prefix, Suffix) = llvm::StringRef(
Type).split(NamePlaceholder);
5233 Prefix = Prefix.rtrim();
5234 Suffix = Suffix.ltrim();
5257 ResultBuilder Results(
5261 Data.IsParenthesized
5264 Data.PreferredType));
5267 if (
Data.ObjCCollection)
5268 Results.setFilter(&ResultBuilder::IsObjCCollection);
5269 else if (
Data.IntegralConstantExpression)
5270 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
5272 Results.setFilter(&ResultBuilder::IsOrdinaryName);
5274 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
5276 if (!
Data.PreferredType.isNull())
5277 Results.setPreferredType(
Data.PreferredType.getNonReferenceType());
5280 for (
unsigned I = 0, N =
Data.IgnoreDecls.size(); I != N; ++I)
5281 Results.Ignore(
Data.IgnoreDecls[I]);
5283 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
5284 Consumer.setIsAddressOfOperand(IsAddressOfOperand);
5289 Results.EnterNewScope();
5291 Results.ExitScope();
5293 bool PreferredTypeIsPointer =
false;
5294 if (!
Data.PreferredType.isNull()) {
5295 PreferredTypeIsPointer =
Data.PreferredType->isAnyPointerType() ||
5296 Data.PreferredType->isMemberPointerType() ||
5297 Data.PreferredType->isBlockPointerType();
5298 if (
auto *
Enum =
Data.PreferredType->getAsEnumDecl()) {
5302 CoveredEnumerators());
5307 !
Data.IntegralConstantExpression)
5312 PreferredTypeIsPointer);
5322 Results.getCompletionContext(), Results.data(),
5328 bool IsParenthesized,
5329 bool IsAddressOfOperand) {
5332 IsAddressOfOperand);
5357 if (Protocol->hasDefinition())
5358 return Protocol->getDefinition();
5372 Builder.AddResultTypeChunk(
5374 Policy, Builder.getAllocator()));
5380 Builder.AddPlaceholderChunk(
"...");
5382 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
5387 std::string PlaceholderStr =
5390 if (I == N - 1 && BlockProtoLoc &&
5392 PlaceholderStr +=
", ...";
5395 Builder.AddPlaceholderChunk(
5396 Builder.getAllocator().CopyString(PlaceholderStr));
5406 bool AllowNullaryMethods,
DeclContext *CurContext,
5408 bool IsBaseExprStatement =
false,
5409 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
5417 if (!AddedProperties.insert(P->getIdentifier()).second)
5422 if (!P->getType().getTypePtr()->isBlockPointerType() ||
5423 !IsBaseExprStatement) {
5425 Result(P, Results.getBasePriority(P), std::nullopt);
5426 if (!InOriginalClass)
5428 Results.MaybeAddResult(R, CurContext);
5440 Result(P, Results.getBasePriority(P), std::nullopt);
5441 if (!InOriginalClass)
5443 Results.MaybeAddResult(R, CurContext);
5450 Results.getCodeCompletionTUInfo());
5453 BlockLoc, BlockProtoLoc);
5454 Result R =
Result(Builder.TakeString(), P, Results.getBasePriority(P));
5455 if (!InOriginalClass)
5457 Results.MaybeAddResult(R, CurContext);
5461 if (!P->isReadOnly()) {
5463 Results.getCodeCompletionTUInfo());
5467 Builder.AddTypedTextChunk(
5468 Results.getAllocator().CopyString(P->getName()));
5473 BlockProtoLoc,
true);
5475 Builder.AddPlaceholderChunk(
5476 Builder.getAllocator().CopyString(PlaceholderStr));
5484 Result(Builder.TakeString(), P,
5485 Results.getBasePriority(P) +
5489 if (!InOriginalClass)
5491 Results.MaybeAddResult(R, CurContext);
5495 if (IsClassProperty) {
5504 if (AllowNullaryMethods) {
5509 const IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
5512 if (!AddedProperties.insert(Name).second)
5515 Results.getCodeCompletionTUInfo());
5517 Builder.AddTypedTextChunk(
5518 Results.getAllocator().CopyString(Name->
getName()));
5521 if (!InOriginalClass)
5523 Results.MaybeAddResult(R, CurContext);
5526 if (IsClassProperty) {
5527 for (
const auto *M : Container->
methods()) {
5531 if (!M->getSelector().isUnarySelector() ||
5532 M->getReturnType()->isVoidType() || M->isInstanceMethod())
5537 for (
auto *M : Container->
methods()) {
5538 if (M->getSelector().isUnarySelector())
5546 for (
auto *P : Protocol->protocols())
5548 CurContext, AddedProperties, Results,
5549 IsBaseExprStatement, IsClassProperty,
5552 dyn_cast<ObjCInterfaceDecl>(Container)) {
5553 if (AllowCategories) {
5555 for (
auto *Cat : IFace->known_categories())
5557 CurContext, AddedProperties, Results,
5558 IsBaseExprStatement, IsClassProperty,
5563 for (
auto *I : IFace->all_referenced_protocols())
5565 CurContext, AddedProperties, Results,
5566 IsBaseExprStatement, IsClassProperty,
5570 if (IFace->getSuperClass())
5572 AllowNullaryMethods, CurContext, AddedProperties,
5573 Results, IsBaseExprStatement, IsClassProperty,
5575 }
else if (
const auto *Category =
5576 dyn_cast<ObjCCategoryDecl>(Container)) {
5578 for (
auto *P : Category->protocols())
5580 CurContext, AddedProperties, Results,
5581 IsBaseExprStatement, IsClassProperty,
5590 std::optional<FixItHint> AccessOpFixIt) {
5593 Results.setObjectTypeQualifiers(BaseType.getQualifiers(), BaseKind);
5596 Results.allowNestedNameSpecifiers();
5597 std::vector<FixItHint> FixIts;
5599 FixIts.emplace_back(*AccessOpFixIt);
5600 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
5608 if (!Results.empty()) {
5612 bool IsDependent = BaseType->isDependentType();
5614 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
5632 BaseType = Resolver.
simplifyType(BaseType,
nullptr,
false);
5633 return dyn_cast_if_present<RecordDecl>(
5669 const IdentifierInfo *Name =
nullptr;
5674 std::optional<SmallVector<QualType, 1>> ArgTypes;
5676 enum AccessOperator {
5682 const TypeConstraint *ResultType =
nullptr;
5688 CodeCompletionString *render(Sema &S, CodeCompletionAllocator &Alloc,
5689 CodeCompletionTUInfo &Info)
const {
5690 CodeCompletionBuilder B(Alloc, Info);
5693 std::string AsString;
5695 llvm::raw_string_ostream
OS(AsString);
5696 QualType ExactType = deduceType(*ResultType);
5702 B.AddResultTypeChunk(
Alloc.CopyString(AsString));
5705 B.AddTypedTextChunk(
Alloc.CopyString(Name->
getName()));
5710 for (QualType Arg : *ArgTypes) {
5717 B.AddPlaceholderChunk(
Alloc.CopyString(
5722 return B.TakeString();
5729 ConceptInfo(
const TemplateTypeParmType &BaseType, Scope *S) {
5730 auto *TemplatedEntity = getTemplatedEntity(BaseType.getDecl(), S);
5731 for (
const AssociatedConstraint &AC :
5732 constraintsForTemplatedEntity(TemplatedEntity))
5733 believe(AC.ConstraintExpr, &BaseType);
5736 std::vector<Member> members() {
5737 std::vector<Member> Results;
5738 for (
const auto &E : this->Results)
5739 Results.push_back(E.second);
5740 llvm::sort(Results, [](
const Member &L,
const Member &R) {
5741 return L.Name->getName() <
R.Name->getName();
5748 void believe(
const Expr *E,
const TemplateTypeParmType *
T) {
5751 if (
auto *CSE = dyn_cast<ConceptSpecializationExpr>(E)) {
5762 ConceptDecl *CD = CSE->getConceptDecl();
5765 for (
const auto &Arg : CSE->getTemplateArguments()) {
5766 if (Index >= Params->
size())
5768 if (isApprox(Arg,
T)) {
5769 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Params->
getParam(Index));
5781 }
else if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
5784 if (BO->getOpcode() == BO_LAnd || BO->getOpcode() == BO_LOr) {
5785 believe(BO->getLHS(),
T);
5786 believe(BO->getRHS(),
T);
5788 }
else if (
auto *RE = dyn_cast<RequiresExpr>(E)) {
5790 for (
const concepts::Requirement *Req : RE->getRequirements()) {
5791 if (!Req->isDependent())
5795 if (
auto *TR = dyn_cast<concepts::TypeRequirement>(Req)) {
5797 QualType AssertedType = TR->getType()->getType();
5798 ValidVisitor(
this,
T).TraverseType(AssertedType);
5799 }
else if (
auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
5800 ValidVisitor Visitor(
this,
T);
5804 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
5806 ER->getReturnTypeRequirement().getTypeConstraint();
5807 Visitor.OuterExpr = ER->getExpr();
5809 Visitor.TraverseStmt(ER->getExpr());
5810 }
else if (
auto *NR = dyn_cast<concepts::NestedRequirement>(Req)) {
5811 believe(NR->getConstraintExpr(),
T);
5821 const TemplateTypeParmType *
T;
5823 CallExpr *Caller =
nullptr;
5828 Expr *OuterExpr =
nullptr;
5829 const TypeConstraint *OuterType =
nullptr;
5831 ValidVisitor(ConceptInfo *Outer,
const TemplateTypeParmType *
T)
5832 : Outer(Outer),
T(
T) {
5838 VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E)
override {
5841 if (
Base->isPointerType() && IsArrow) {
5843 Base =
Base->getPointeeType().getTypePtr();
5845 if (isApprox(Base,
T))
5846 addValue(E, E->
getMember(), IsArrow ? Member::Arrow : Member::Dot);
5851 bool VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E)
override {
5853 if (
Qualifier.getKind() == NestedNameSpecifier::Kind::Type &&
5860 bool VisitDependentNameType(DependentNameType *DNT)
override {
5861 NestedNameSpecifier Q = DNT->getQualifier();
5862 if (Q.
getKind() == NestedNameSpecifier::Kind::Type &&
5864 addType(DNT->getIdentifier());
5873 if (NNS.
getKind() == NestedNameSpecifier::Kind::Type) {
5875 if (NestedNameSpecifier Q = NNST->
getPrefix();
5876 Q.
getKind() == NestedNameSpecifier::Kind::Type &&
5878 if (
const auto *DNT = dyn_cast_or_null<DependentNameType>(NNST))
5879 addType(DNT->getIdentifier());
5890 bool VisitCallExpr(CallExpr *CE)
override {
5897 void addResult(
Member &&M) {
5898 auto R = Outer->Results.try_emplace(M.Name);
5903 std::make_tuple(M.ArgTypes.has_value(), M.ResultType !=
nullptr,
5904 M.Operator) > std::make_tuple(O.ArgTypes.has_value(),
5905 O.ResultType !=
nullptr,
5910 void addType(
const IdentifierInfo *Name) {
5915 M.Operator = Member::Colons;
5916 addResult(std::move(M));
5919 void addValue(Expr *E, DeclarationName Name,
5920 Member::AccessOperator Operator) {
5925 Result.Operator = Operator;
5928 if (Caller !=
nullptr && Callee == E) {
5929 Result.ArgTypes.emplace();
5930 for (
const auto *Arg : Caller->
arguments())
5931 Result.ArgTypes->push_back(Arg->getType());
5932 if (Caller == OuterExpr) {
5933 Result.ResultType = OuterType;
5937 Result.ResultType = OuterType;
5939 addResult(std::move(
Result));
5943 static bool isApprox(
const TemplateArgument &Arg,
const Type *
T) {
5948 static bool isApprox(
const Type *T1,
const Type *T2) {
5957 static DeclContext *getTemplatedEntity(
const TemplateTypeParmDecl *D,
5961 Scope *Inner =
nullptr;
5964 return Inner ? Inner->
getEntity() :
nullptr;
5973 static SmallVector<AssociatedConstraint, 1>
5974 constraintsForTemplatedEntity(DeclContext *DC) {
5975 SmallVector<AssociatedConstraint, 1>
Result;
5980 TD->getAssociatedConstraints(
Result);
5982 if (
const auto *CTPSD =
5983 dyn_cast<ClassTemplatePartialSpecializationDecl>(DC))
5984 CTPSD->getAssociatedConstraints(
Result);
5985 if (
const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl>(DC))
5986 VTPSD->getAssociatedConstraints(
Result);
5992 static QualType deduceType(
const TypeConstraint &
T) {
5995 DeclarationName DN =
5996 T.getConceptReference()->getConceptNameInfo().getName();
5998 if (
const auto *Args =
T.getTemplateArgsAsWritten())
5999 if (Args->getNumTemplateArgs() == 1) {
6000 const auto &Arg = Args->arguments().front().getArgument();
6007 llvm::DenseMap<const IdentifierInfo *, Member> Results;
6014QualType getApproximateType(
const Expr *E, HeuristicResolver &Resolver) {
6028Expr *unwrapParenList(Expr *Base) {
6029 if (
auto *PLE = llvm::dyn_cast_or_null<ParenListExpr>(Base)) {
6030 if (PLE->getNumExprs() == 0)
6032 Base = PLE->getExpr(PLE->getNumExprs() - 1);
6041 bool IsBaseExprStatement,
QualType PreferredType) {
6043 OtherOpBase = unwrapParenList(OtherOpBase);
6048 SemaRef.PerformMemberExprBaseConversion(
Base, IsArrow);
6052 getApproximateType(ConvertedBase.
get(),
Resolver);
6058 !PointeeType.isNull()) {
6059 ConvertedBaseType = PointeeType;
6078 &ResultBuilder::IsMember);
6080 auto DoCompletion = [&](
Expr *
Base,
bool IsArrow,
6081 std::optional<FixItHint> AccessOpFixIt) ->
bool {
6086 SemaRef.PerformMemberExprBaseConversion(
Base, IsArrow);
6092 if (BaseType.isNull())
6098 !PointeeType.isNull()) {
6099 BaseType = PointeeType;
6101 }
else if (BaseType->isObjCObjectPointerType() ||
6102 BaseType->isTemplateTypeParmType()) {
6111 RD, std::move(AccessOpFixIt));
6112 }
else if (
const auto *TTPT =
6113 dyn_cast<TemplateTypeParmType>(BaseType.getTypePtr())) {
6115 IsArrow ? ConceptInfo::Member::Arrow : ConceptInfo::Member::Dot;
6116 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
6117 if (R.Operator != Operator)
6123 Result.FixIts.push_back(*AccessOpFixIt);
6124 Results.AddResult(std::move(
Result));
6126 }
else if (!IsArrow && BaseType->isObjCObjectPointerType()) {
6130 if (AccessOpFixIt) {
6138 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
6141 AddedProperties, Results, IsBaseExprStatement);
6147 SemaRef.CurContext, AddedProperties, Results,
6148 IsBaseExprStatement,
false,
6150 }
else if ((IsArrow && BaseType->isObjCObjectPointerType()) ||
6151 (!IsArrow && BaseType->isObjCObjectType())) {
6155 if (AccessOpFixIt) {
6161 Class = ObjCPtr->getInterfaceDecl();
6167 CodeCompletionDeclConsumer Consumer(Results,
Class, BaseType);
6168 Results.setFilter(&ResultBuilder::IsObjCIvar);
6180 Results.EnterNewScope();
6182 bool CompletionSucceded = DoCompletion(
Base, IsArrow, std::nullopt);
6186 CompletionSucceded |= DoCompletion(
6187 OtherOpBase, !IsArrow,
6191 Results.ExitScope();
6193 if (!CompletionSucceded)
6198 Results.getCompletionContext(), Results.data(),
6204 bool IsBaseExprStatement) {
6207 SemaRef.ObjC().getObjCInterfaceDecl(ClassNamePtr, ClassNameLoc);
6214 &ResultBuilder::IsMember);
6215 Results.EnterNewScope();
6219 AddedProperties, Results, IsBaseExprStatement,
6221 Results.ExitScope();
6223 Results.getCompletionContext(), Results.data(),
6231 ResultBuilder::LookupFilter Filter =
nullptr;
6236 Filter = &ResultBuilder::IsEnum;
6241 Filter = &ResultBuilder::IsUnion;
6248 Filter = &ResultBuilder::IsClassOrStruct;
6253 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
6258 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
6261 Results.setFilter(Filter);
6268 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
6275 Results.getCompletionContext(), Results.data(),
6282 Results.AddResult(
"const");
6284 Results.AddResult(
"volatile");
6286 Results.AddResult(
"restrict");
6288 Results.AddResult(
"_Atomic");
6290 Results.AddResult(
"__unaligned");
6297 Results.EnterNewScope();
6299 Results.ExitScope();
6301 Results.getCompletionContext(), Results.data(),
6310 Results.EnterNewScope();
6313 Results.AddResult(
"noexcept");
6317 Results.AddResult(
"final");
6319 Results.AddResult(
"override");
6322 Results.ExitScope();
6324 Results.getCompletionContext(), Results.data(),
6337 SemaRef.getCurFunction()->SwitchStack.back().getPointer();
6345 Data.IntegralConstantExpression =
true;
6354 CoveredEnumerators Enumerators;
6356 SC = SC->getNextSwitchCase()) {
6357 CaseStmt *Case = dyn_cast<CaseStmt>(SC);
6362 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
6364 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
6384 Enumerators.SuggestedQualifier = DRE->getQualifier();
6399 Results.getCompletionContext(), Results.data(),
6404 if (Args.size() && !Args.data())
6407 for (
unsigned I = 0; I != Args.size(); ++I)
6428 if (Candidate.Function) {
6429 if (Candidate.Function->isDeleted())
6432 Candidate.Function) &&
6433 Candidate.Function->getNumParams() <= ArgSize &&
6442 if (Candidate.Viable)
6456 for (
auto &Candidate : Candidates) {
6457 QualType CandidateParamType = Candidate.getParamType(N);
6458 if (CandidateParamType.
isNull())
6460 if (ParamType.
isNull()) {
6461 ParamType = CandidateParamType;
6478 if (Candidates.empty())
6482 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc,
6490 Fn = unwrapParenList(Fn);
6501 auto ArgsWithoutDependentTypes =
6506 Expr *NakedFn = Fn->IgnoreParenCasts();
6512 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
6513 SemaRef.AddOverloadedCallCandidates(ULE, ArgsWithoutDependentTypes,
6516 }
else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
6518 if (UME->hasExplicitTemplateArgs()) {
6519 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
6520 TemplateArgs = &TemplateArgsBuffer;
6525 1, UME->isImplicitAccess() ?
nullptr : UME->getBase());
6526 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6527 ArgsWithoutDependentTypes.end());
6529 Decls.
append(UME->decls_begin(), UME->decls_end());
6530 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
6531 SemaRef.AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
6534 FirstArgumentIsBase);
6537 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
6538 FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl());
6539 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
6540 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
6546 SemaRef.AddOverloadCandidate(FD,
6548 ArgsWithoutDependentTypes, CandidateSet,
6558 getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
6560 SemaRef.LookupQualifiedName(R, DC);
6561 R.suppressDiagnostics();
6563 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6564 ArgsWithoutDependentTypes.end());
6565 SemaRef.AddFunctionCandidates(R.asUnresolvedSet(), ArgExprs,
6578 if (!
T->getPointeeType().isNull())
6579 T =
T->getPointeeType();
6582 if (!
SemaRef.TooManyArguments(FP->getNumParams(),
6583 ArgsWithoutDependentTypes.size(),
6619static std::optional<unsigned>
6622 static constexpr unsigned Invalid = std::numeric_limits<unsigned>::max();
6628 unsigned ArgsAfterDesignator = 0;
6629 for (
const Expr *Arg : Args) {
6630 if (
const auto *DIE = dyn_cast<DesignatedInitExpr>(Arg)) {
6631 if (DIE->size() == 1 && DIE->getDesignator(0)->isFieldDesignator()) {
6632 DesignatedFieldName = DIE->getDesignator(0)->getFieldName();
6633 ArgsAfterDesignator = 0;
6640 ++ArgsAfterDesignator;
6643 if (!DesignatedFieldName)
6644 return std::nullopt;
6648 unsigned DesignatedIndex = 0;
6649 const FieldDecl *DesignatedField =
nullptr;
6650 for (
const auto *Field :
Aggregate.getAggregate()->fields()) {
6651 if (Field->getIdentifier() == DesignatedFieldName) {
6652 DesignatedField = Field;
6657 if (!DesignatedField)
6661 unsigned AggregateSize =
Aggregate.getNumParams();
6662 while (DesignatedIndex < AggregateSize &&
6663 Aggregate.getParamDecl(DesignatedIndex) != DesignatedField)
6667 return DesignatedIndex + ArgsAfterDesignator + 1;
6690 if (Braced && !RD->
isUnion() &&
6695 if (
auto NextIndex =
6698 if (*NextIndex >= AggregateSize)
6700 Results.push_back(AggregateSig);
6706 if (Args.size() < AggregateSize)
6707 Results.push_back(AggregateSig);
6717 if (
auto *FD = dyn_cast<FunctionDecl>(
C)) {
6721 SemaRef.isInitListConstructor(FD))
6728 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
6730 SemaRef.isInitListConstructor(FTD->getTemplatedDecl()))
6733 SemaRef.AddTemplateOverloadCandidate(
6735 nullptr, Args, CandidateSet,
6756 dyn_cast<CXXConstructorDecl>(ConstructorDecl);
6761 Constructor->getParent(), SS, TemplateTypeTy, II))
6763 MemberDecl->getLocation(), ArgExprs,
6764 OpenParLoc, Braced);
6772 if (Index < Params.
size())
6775 Param = Params.
asArray().back();
6781 return llvm::isa<TemplateTypeParmDecl>(Param);
6783 return llvm::isa<NonTypeTemplateParmDecl>(Param);
6785 return llvm::isa<TemplateTemplateParmDecl>(Param);
6787 llvm_unreachable(
"Unhandled switch case");
6799 bool Matches =
true;
6800 for (
unsigned I = 0; I < Args.size(); ++I) {
6807 Results.emplace_back(TD);
6811 if (
const auto *TD =
Template.getAsTemplateDecl()) {
6813 }
else if (
const auto *OTS =
Template.getAsOverloadedTemplate()) {
6815 if (
const auto *TD = llvm::dyn_cast<TemplateDecl>(ND))
6826 if (
const auto *FD = llvm::dyn_cast<FieldDecl>(
Member))
6828 if (
const auto *IFD = llvm::dyn_cast<IndirectFieldDecl>(
Member))
6829 return IFD->getAnonField();
6840 if (BaseType.isNull())
6844 if (D.isArrayDesignator() || D.isArrayRangeDesignator()) {
6845 if (BaseType->isDependentType()) {
6846 BaseType = Context.DependentTy;
6849 const ArrayType *AT = Context.getAsArrayType(BaseType);
6856 assert(D.isFieldDesignator());
6857 if (BaseType->isDependentType()) {
6858 BaseType = Context.DependentTy;
6866 const FieldDecl *MemberDecl = LookupField(RD, D);
6879 if (BaseType.isNull())
6882 if (!RD || RD->fields().empty())
6890 Results.EnterNewScope();
6891 for (
const Decl *D : RD->decls()) {
6893 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(D))
6894 FD = IFD->getAnonField();
6895 else if (
auto *DFD = dyn_cast<FieldDecl>(D))
6902 ResultBuilder::Result
Result(FD, Results.getBasePriority(FD));
6905 Results.ExitScope();
6907 Results.getCompletionContext(), Results.data(),
6919 SemaRef.LookupQualifiedName(R, RD);
6924 if (
auto *FD = dyn_cast<FieldDecl>(ND))
6926 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(ND))
6927 return IFD->getAnonField();
6933 if (BaseType.isNull())
6944 &ResultBuilder::IsOffsetofField);
6946 Results.EnterNewScope();
6947 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType);
6955 Results.ExitScope();
6958 Results.getCompletionContext(), Results.data(),
6963 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
6972 Data.IgnoreDecls.push_back(VD);
6982 Results.getCodeCompletionTUInfo());
6984 if (!AfterExclaim) {
6985 if (Results.includeCodePatterns()) {
6986 Builder.AddTypedTextChunk(
"constexpr");
6989 Builder.AddPlaceholderChunk(
"condition");
6994 Builder.AddPlaceholderChunk(
"statements");
6997 Results.AddResult({Builder.TakeString()});
6999 Results.AddResult({
"constexpr"});
7004 if (Results.includeCodePatterns()) {
7005 Builder.AddTypedTextChunk(
"consteval");
7009 Builder.AddPlaceholderChunk(
"statements");
7012 Results.AddResult({Builder.TakeString()});
7014 Results.AddResult({
"consteval"});
7019 Results.getCompletionContext(), Results.data(),
7027 Results.setFilter(&ResultBuilder::IsOrdinaryName);
7028 Results.EnterNewScope();
7030 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7039 Results.getCodeCompletionTUInfo());
7041 auto AddElseBodyPattern = [&] {
7046 Builder.AddPlaceholderChunk(
"statements");
7052 Builder.AddPlaceholderChunk(
"statement");
7056 Builder.AddTypedTextChunk(
"else");
7057 if (Results.includeCodePatterns())
7058 AddElseBodyPattern();
7059 Results.AddResult(Builder.TakeString());
7062 Builder.AddTypedTextChunk(
"else if");
7066 Builder.AddPlaceholderChunk(
"condition");
7068 Builder.AddPlaceholderChunk(
"expression");
7070 if (Results.includeCodePatterns()) {
7071 AddElseBodyPattern();
7073 Results.AddResult(Builder.TakeString());
7075 Results.ExitScope();
7084 Results.getCompletionContext(), Results.data(),
7090 bool IsAddressOfOperand,
bool IsInDeclarationContext,
QualType BaseType,
7109 if (!PreferredType.
isNull())
7110 DummyResults.setPreferredType(PreferredType);
7112 CodeCompletionDeclConsumer Consumer(DummyResults, S->
getEntity(),
7119 DummyResults.getCompletionContext(),
nullptr, 0);
7126 std::optional<Sema::ContextRAII> SimulateContext;
7129 if (IsInDeclarationContext && Ctx !=
nullptr)
7130 SimulateContext.emplace(
SemaRef, Ctx);
7136 if (Ctx ==
nullptr ||
SemaRef.RequireCompleteDeclContext(SS, Ctx))
7142 if (!PreferredType.
isNull())
7143 Results.setPreferredType(PreferredType);
7144 Results.EnterNewScope();
7150 Results.AddResult(
"template");
7155 if (
const auto *TTPT = dyn_cast<TemplateTypeParmType>(NNS.
getAsType())) {
7156 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
7157 if (R.Operator != ConceptInfo::Member::Colons)
7171 if (Ctx && !EnteringContext)
7173 Results.ExitScope();
7177 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
7178 Consumer.setIsInDeclarationContext(IsInDeclarationContext);
7179 Consumer.setIsAddressOfOperand(IsAddressOfOperand);
7185 SimulateContext.reset();
7187 Results.getCompletionContext(), Results.data(),
7198 Context.setIsUsingDeclaration(
true);
7202 &ResultBuilder::IsNestedNameSpecifier);
7203 Results.EnterNewScope();
7211 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7215 Results.ExitScope();
7218 Results.getCompletionContext(), Results.data(),
7231 &ResultBuilder::IsNamespaceOrAlias);
7232 Results.EnterNewScope();
7233 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7237 Results.ExitScope();
7239 Results.getCompletionContext(), Results.data(),
7251 bool SuppressedGlobalResults =
7256 SuppressedGlobalResults
7259 &ResultBuilder::IsNamespace);
7261 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
7266 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
7271 OrigToLatest[NS->getFirstDecl()] = *NS;
7275 Results.EnterNewScope();
7276 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
7277 NS = OrigToLatest.begin(),
7278 NSEnd = OrigToLatest.end();
7283 SemaRef.CurContext,
nullptr,
false);
7284 Results.ExitScope();
7288 Results.getCompletionContext(), Results.data(),
7300 &ResultBuilder::IsNamespaceOrAlias);
7301 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7306 Results.getCompletionContext(), Results.data(),
7318 &ResultBuilder::IsType);
7319 Results.EnterNewScope();
7323#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
7324 if (OO_##Name != OO_Conditional) \
7325 Results.AddResult(Result(Spelling));
7326#include "clang/Basic/OperatorKinds.def"
7329 Results.allowNestedNameSpecifiers();
7330 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7337 Results.ExitScope();
7340 Results.getCompletionContext(), Results.data(),
7349 SemaRef.AdjustDeclIfTemplate(ConstructorD);
7351 auto *
Constructor = dyn_cast<CXXConstructorDecl>(ConstructorD);
7358 Results.EnterNewScope();
7363 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
7364 if (Initializers[I]->isBaseInitializer())
7366 QualType(Initializers[I]->getBaseClass(), 0)));
7368 InitializedFields.insert(
7374 bool SawLastInitializer = Initializers.empty();
7377 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
7379 Results.getCodeCompletionTUInfo());
7380 Builder.AddTypedTextChunk(Name);
7382 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND))
7384 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
7386 FunTemplDecl->getTemplatedDecl(), Builder);
7388 return Builder.TakeString();
7390 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
7393 Results.getCodeCompletionTUInfo());
7394 Builder.AddTypedTextChunk(Name);
7396 Builder.AddPlaceholderChunk(
Type);
7400 Builder.TakeString(), ND,
7404 return Results.AddResult(CCR);
7407 Builder.TakeString(),
7410 auto AddCtorsWithName = [&](
const CXXRecordDecl *RD,
unsigned int Priority,
7411 const char *Name,
const FieldDecl *FD) {
7413 return AddDefaultCtorInit(Name,
7414 FD ? Results.getAllocator().CopyString(
7415 FD->getType().getAsString(Policy))
7419 if (Ctors.begin() == Ctors.end())
7420 return AddDefaultCtorInit(Name, Name, RD);
7424 Results.AddResult(CCR);
7428 const char *BaseName =
7429 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
7430 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
7435 auto AddField = [&](
const FieldDecl *FD) {
7436 const char *FieldName =
7437 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
7438 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
7444 for (
const auto &
Base : ClassDecl->
bases()) {
7445 if (!InitializedBases
7448 SawLastInitializer =
7449 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7451 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7456 SawLastInitializer =
false;
7460 for (
const auto &
Base : ClassDecl->
vbases()) {
7461 if (!InitializedBases
7464 SawLastInitializer =
7465 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7467 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7472 SawLastInitializer =
false;
7476 for (
auto *Field : ClassDecl->
fields()) {
7477 if (!InitializedFields.insert(
cast<FieldDecl>(Field->getCanonicalDecl()))
7479 SawLastInitializer = !Initializers.empty() &&
7480 Initializers.back()->isAnyMemberInitializer() &&
7481 Initializers.back()->getAnyMember() == Field;
7485 if (!Field->getDeclName())
7489 SawLastInitializer =
false;
7491 Results.ExitScope();
7494 Results.getCompletionContext(), Results.data(),
7509 bool AfterAmpersand) {
7513 Results.EnterNewScope();
7517 bool IncludedThis =
false;
7520 IncludedThis =
true;
7529 for (
const auto *D : S->
decls()) {
7530 const auto *Var = dyn_cast<VarDecl>(D);
7531 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
7534 if (
Known.insert(Var->getIdentifier()).second)
7536 SemaRef.CurContext,
nullptr,
false);
7544 Results.ExitScope();
7547 Results.getCompletionContext(), Results.data(),
7557 auto ShouldAddDefault = [&D,
this]() {
7569 auto Op = Id.OperatorFunctionId.Operator;
7572 if (Op == OverloadedOperatorKind::OO_Equal)
7575 (Op == OverloadedOperatorKind::OO_EqualEqual ||
7576 Op == OverloadedOperatorKind::OO_ExclaimEqual ||
7577 Op == OverloadedOperatorKind::OO_Less ||
7578 Op == OverloadedOperatorKind::OO_LessEqual ||
7579 Op == OverloadedOperatorKind::OO_Greater ||
7580 Op == OverloadedOperatorKind::OO_GreaterEqual ||
7581 Op == OverloadedOperatorKind::OO_Spaceship))
7587 Results.EnterNewScope();
7588 if (ShouldAddDefault())
7589 Results.AddResult(
"default");
7592 Results.AddResult(
"delete");
7593 Results.ExitScope();
7595 Results.getCompletionContext(), Results.data(),
7601#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
7604 ResultBuilder &Results,
bool NeedAt) {
7610 Results.getCodeCompletionTUInfo());
7611 if (LangOpts.ObjC) {
7615 Builder.AddPlaceholderChunk(
"property");
7616 Results.AddResult(
Result(Builder.TakeString()));
7621 Builder.AddPlaceholderChunk(
"property");
7622 Results.AddResult(
Result(Builder.TakeString()));
7627 ResultBuilder &Results,
bool NeedAt) {
7633 if (LangOpts.ObjC) {
7648 Results.getCodeCompletionTUInfo());
7653 Builder.AddPlaceholderChunk(
"name");
7654 Results.AddResult(
Result(Builder.TakeString()));
7656 if (Results.includeCodePatterns()) {
7662 Builder.AddPlaceholderChunk(
"class");
7663 Results.AddResult(
Result(Builder.TakeString()));
7668 Builder.AddPlaceholderChunk(
"protocol");
7669 Results.AddResult(
Result(Builder.TakeString()));
7674 Builder.AddPlaceholderChunk(
"class");
7675 Results.AddResult(
Result(Builder.TakeString()));
7679 Builder.AddTypedTextChunk(
7682 Builder.AddPlaceholderChunk(
"alias");
7684 Builder.AddPlaceholderChunk(
"class");
7685 Results.AddResult(
Result(Builder.TakeString()));
7687 if (Results.getSema().getLangOpts().Modules) {
7691 Builder.AddPlaceholderChunk(
"module");
7692 Results.AddResult(
Result(Builder.TakeString()));
7700 Results.EnterNewScope();
7703 else if (
SemaRef.CurContext->isObjCContainer())
7707 Results.ExitScope();
7709 Results.getCompletionContext(), Results.data(),
7716 Results.getCodeCompletionTUInfo());
7719 const char *EncodeType =
"char[]";
7720 if (Results.getSema().getLangOpts().CPlusPlus ||
7721 Results.getSema().getLangOpts().ConstStrings)
7722 EncodeType =
"const char[]";
7723 Builder.AddResultTypeChunk(EncodeType);
7726 Builder.AddPlaceholderChunk(
"type-name");
7728 Results.AddResult(
Result(Builder.TakeString()));
7731 Builder.AddResultTypeChunk(
"Protocol *");
7734 Builder.AddPlaceholderChunk(
"protocol-name");
7736 Results.AddResult(
Result(Builder.TakeString()));
7739 Builder.AddResultTypeChunk(
"SEL");
7742 Builder.AddPlaceholderChunk(
"selector");
7744 Results.AddResult(
Result(Builder.TakeString()));
7747 Builder.AddResultTypeChunk(
"NSString *");
7749 Builder.AddPlaceholderChunk(
"string");
7750 Builder.AddTextChunk(
"\"");
7751 Results.AddResult(
Result(Builder.TakeString()));
7754 Builder.AddResultTypeChunk(
"NSArray *");
7756 Builder.AddPlaceholderChunk(
"objects, ...");
7758 Results.AddResult(
Result(Builder.TakeString()));
7761 Builder.AddResultTypeChunk(
"NSDictionary *");
7763 Builder.AddPlaceholderChunk(
"key");
7766 Builder.AddPlaceholderChunk(
"object, ...");
7768 Results.AddResult(
Result(Builder.TakeString()));
7771 Builder.AddResultTypeChunk(
"id");
7773 Builder.AddPlaceholderChunk(
"expression");
7775 Results.AddResult(
Result(Builder.TakeString()));
7781 Results.getCodeCompletionTUInfo());
7783 if (Results.includeCodePatterns()) {
7788 Builder.AddPlaceholderChunk(
"statements");
7790 Builder.AddTextChunk(
"@catch");
7792 Builder.AddPlaceholderChunk(
"parameter");
7795 Builder.AddPlaceholderChunk(
"statements");
7797 Builder.AddTextChunk(
"@finally");
7799 Builder.AddPlaceholderChunk(
"statements");
7801 Results.AddResult(
Result(Builder.TakeString()));
7807 Builder.AddPlaceholderChunk(
"expression");
7808 Results.AddResult(
Result(Builder.TakeString()));
7810 if (Results.includeCodePatterns()) {
7815 Builder.AddPlaceholderChunk(
"expression");
7818 Builder.AddPlaceholderChunk(
"statements");
7820 Results.AddResult(
Result(Builder.TakeString()));
7825 ResultBuilder &Results,
bool NeedAt) {
7838 Results.EnterNewScope();
7840 Results.ExitScope();
7842 Results.getCompletionContext(), Results.data(),
7850 Results.EnterNewScope();
7853 Results.ExitScope();
7855 Results.getCompletionContext(), Results.data(),
7863 Results.EnterNewScope();
7865 Results.ExitScope();
7867 Results.getCompletionContext(), Results.data(),
7875 if (Attributes & NewFlag)
7878 Attributes |= NewFlag;
7886 unsigned AssignCopyRetMask =
7892 if (AssignCopyRetMask &&
7914 Results.EnterNewScope();
7951 Results.getCodeCompletionTUInfo());
7960 Results.getCodeCompletionTUInfo());
7973 Results.ExitScope();
7975 Results.getCompletionContext(), Results.data(),
7989 bool AllowSameLength =
true) {
7990 unsigned NumSelIdents = SelIdents.size();
8003 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
8006 for (
unsigned I = 0; I != NumSelIdents; ++I)
8016 bool AllowSameLength =
true) {
8050 ResultBuilder &Results,
bool InOriginalClass =
true,
8051 bool IsRootClass =
false) {
8055 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
8059 if (M->isInstanceMethod() == WantInstanceMethods ||
8060 (IsRootClass && !WantInstanceMethods)) {
8066 if (!Selectors.insert(M->getSelector()).second)
8070 Result(M, Results.getBasePriority(M), std::nullopt);
8071 R.StartParameter = SelIdents.size();
8072 R.AllParametersAreInformative = (WantKind !=
MK_Any);
8073 if (!InOriginalClass)
8075 Results.MaybeAddResult(R, CurContext);
8080 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
8081 if (Protocol->hasDefinition()) {
8083 Protocol->getReferencedProtocols();
8085 E = Protocols.
end();
8087 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
8088 Selectors, AllowSameLength, Results,
false, IsRootClass);
8097 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
8098 Selectors, AllowSameLength, Results,
false, IsRootClass);
8102 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
8103 CurContext, Selectors, AllowSameLength, Results,
8104 InOriginalClass, IsRootClass);
8108 CatDecl->getReferencedProtocols();
8110 E = Protocols.
end();
8112 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
8113 Selectors, AllowSameLength, Results,
false, IsRootClass);
8117 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
8118 Selectors, AllowSameLength, Results, InOriginalClass,
8126 SelIdents, CurContext, Selectors, AllowSameLength, Results,
8131 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
8132 Selectors, AllowSameLength, Results, InOriginalClass,
8139 dyn_cast_or_null<ObjCInterfaceDecl>(
SemaRef.CurContext);
8142 dyn_cast_or_null<ObjCCategoryDecl>(
SemaRef.CurContext))
8143 Class = Category->getClassInterface();
8153 Results.EnterNewScope();
8159 Results.ExitScope();
8161 Results.getCompletionContext(), Results.data(),
8168 dyn_cast_or_null<ObjCInterfaceDecl>(
SemaRef.CurContext);
8171 dyn_cast_or_null<ObjCCategoryDecl>(
SemaRef.CurContext))
8172 Class = Category->getClassInterface();
8182 Results.EnterNewScope();
8189 Results.ExitScope();
8191 Results.getCompletionContext(), Results.data(),
8200 Results.EnterNewScope();
8203 bool AddedInOut =
false;
8206 Results.AddResult(
"in");
8207 Results.AddResult(
"inout");
8212 Results.AddResult(
"out");
8214 Results.AddResult(
"inout");
8219 Results.AddResult(
"bycopy");
8220 Results.AddResult(
"byref");
8221 Results.AddResult(
"oneway");
8224 Results.AddResult(
"nonnull");
8225 Results.AddResult(
"nullable");
8226 Results.AddResult(
"null_unspecified");
8234 SemaRef.PP.isMacroDefined(
"IBAction")) {
8236 Results.getCodeCompletionTUInfo(),
8238 Builder.AddTypedTextChunk(
"IBAction");
8240 Builder.AddPlaceholderChunk(
"selector");
8243 Builder.AddTextChunk(
"id");
8245 Builder.AddTextChunk(
"sender");
8256 Results.ExitScope();
8259 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
8260 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
8269 Results.getCompletionContext(), Results.data(),
8278 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(E);
8296 switch (Msg->getReceiverKind()) {
8300 IFace = ObjType->getInterface();
8304 QualType T = Msg->getInstanceReceiver()->getType();
8306 IFace = Ptr->getInterfaceDecl();
8319 if (Method->isInstanceMethod())
8320 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
8321 .Case(
"retain", IFace)
8322 .Case(
"strong", IFace)
8323 .Case(
"autorelease", IFace)
8324 .Case(
"copy", IFace)
8325 .Case(
"copyWithZone", IFace)
8326 .Case(
"mutableCopy", IFace)
8327 .Case(
"mutableCopyWithZone", IFace)
8328 .Case(
"awakeFromCoder", IFace)
8329 .Case(
"replacementObjectFromCoder", IFace)
8330 .Case(
"class", IFace)
8331 .Case(
"classForCoder", IFace)
8332 .Case(
"superclass", Super)
8335 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
8337 .Case(
"alloc", IFace)
8338 .Case(
"allocWithZone", IFace)
8339 .Case(
"class", IFace)
8340 .Case(
"superclass", Super)
8360static ObjCMethodDecl *
8363 ResultBuilder &Results) {
8374 while ((Class = Class->getSuperClass()) && !SuperMethod) {
8376 SuperMethod = Class->getMethod(CurMethod->
getSelector(),
8381 for (
const auto *Cat : Class->known_categories()) {
8382 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
8400 CurP != CurPEnd; ++CurP, ++SuperP) {
8403 (*SuperP)->getType()))
8407 if (!(*CurP)->getIdentifier())
8413 Results.getCodeCompletionTUInfo());
8417 Results.getCompletionContext().getBaseType(), Builder);
8420 if (NeedSuperKeyword) {
8421 Builder.AddTypedTextChunk(
"super");
8427 if (NeedSuperKeyword)
8428 Builder.AddTextChunk(
8431 Builder.AddTypedTextChunk(
8435 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
8436 if (I > SelIdents.size())
8439 if (I < SelIdents.size())
8440 Builder.AddInformativeChunk(
8442 else if (NeedSuperKeyword || I > SelIdents.size()) {
8443 Builder.AddTextChunk(
8445 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8446 (*CurP)->getIdentifier()->getName()));
8448 Builder.AddTypedTextChunk(
8450 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8451 (*CurP)->getIdentifier()->getName()));
8463 ResultBuilder Results(
8468 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
8469 : &ResultBuilder::IsObjCMessageReceiver);
8471 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
8472 Results.EnterNewScope();
8481 if (Iface->getSuperClass()) {
8482 Results.AddResult(
Result(
"super"));
8490 Results.ExitScope();
8495 Results.getCompletionContext(), Results.data(),
8505 CDecl = CurMethod->getClassInterface();
8514 if (CurMethod->isInstanceMethod()) {
8519 AtArgumentExpression, CDecl);
8529 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
8531 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
8533 getASTContext().getTypeDeclType(TD)->getAs<ObjCObjectType>())
8534 CDecl = Iface->getInterface();
8544 SemaRef.ActOnIdExpression(S, SS, TemplateKWLoc,
id,
8548 SelIdents, AtArgumentExpression);
8558 AtArgumentExpression,
8565 unsigned NumSelIdents) {
8567 ASTContext &Context = Results.getSema().Context;
8571 Result *ResultsData = Results.data();
8572 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
8573 Result &R = ResultsData[I];
8574 if (R.Kind == Result::RK_Declaration &&
8576 if (R.Priority <= BestPriority) {
8578 if (NumSelIdents <= Method->param_size()) {
8580 Method->parameters()[NumSelIdents - 1]->getType();
8581 if (R.Priority < BestPriority || PreferredType.
isNull()) {
8582 BestPriority = R.Priority;
8583 PreferredType = MyPreferredType;
8584 }
else if (!Context.hasSameUnqualifiedType(PreferredType,
8593 return PreferredType;
8599 bool AtArgumentExpression,
bool IsSuper,
8600 ResultBuilder &Results) {
8615 Results.EnterNewScope();
8622 Results.Ignore(SuperMethod);
8628 Results.setPreferredSelector(CurMethod->getSelector());
8633 Selectors, AtArgumentExpression, Results);
8651 for (SemaObjC::GlobalMethodPool::iterator
8656 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
8660 Result R(MethList->getMethod(),
8661 Results.getBasePriority(MethList->getMethod()),
8663 R.StartParameter = SelIdents.size();
8664 R.AllParametersAreInformative =
false;
8665 Results.MaybeAddResult(R, SemaRef.
CurContext);
8670 Results.ExitScope();
8675 bool AtArgumentExpression,
bool IsSuper) {
8679 ResultBuilder Results(
8686 AtArgumentExpression, IsSuper, Results);
8693 if (AtArgumentExpression) {
8696 if (PreferredType.
isNull())
8704 Results.getCompletionContext(), Results.data(),
8725 RecExpr = Conv.
get();
8729 : Super ? Context.getObjCObjectPointerType(
8730 Context.getObjCInterfaceType(Super))
8731 : Context.getObjCIdType();
8741 AtArgumentExpression, Super);
8744 Context.getObjCObjectPointerType(Context.getObjCInterfaceType(IFace));
8749 RecExpr = Conv.
get();
8750 ReceiverType = RecExpr->
getType();
8755 ResultBuilder Results(
8759 ReceiverType, SelIdents));
8761 Results.EnterNewScope();
8768 Results.Ignore(SuperMethod);
8774 Results.setPreferredSelector(CurMethod->getSelector());
8787 Selectors, AtArgumentExpression, Results);
8794 for (
auto *I : QualID->quals())
8796 AtArgumentExpression, Results);
8803 SemaRef.CurContext, Selectors, AtArgumentExpression,
8807 for (
auto *I : IFacePtr->quals())
8809 AtArgumentExpression, Results);
8819 for (uint32_t I = 0,
8820 N =
SemaRef.ExternalSource->GetNumExternalSelectors();
8826 SemaRef.ObjC().ReadMethodPool(Sel);
8830 for (SemaObjC::GlobalMethodPool::iterator
8831 M =
SemaRef.ObjC().MethodPool.begin(),
8832 MEnd =
SemaRef.ObjC().MethodPool.end();
8835 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
8839 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
8842 Result R(MethList->getMethod(),
8843 Results.getBasePriority(MethList->getMethod()),
8845 R.StartParameter = SelIdents.size();
8846 R.AllParametersAreInformative =
false;
8847 Results.MaybeAddResult(R,
SemaRef.CurContext);
8851 Results.ExitScope();
8858 if (AtArgumentExpression) {
8861 if (PreferredType.
isNull())
8869 Results.getCompletionContext(), Results.data(),
8876 Data.ObjCCollection =
true;
8882 Data.IgnoreDecls.push_back(*I);
8894 for (uint32_t I = 0, N =
SemaRef.ExternalSource->GetNumExternalSelectors();
8900 SemaRef.ObjC().ReadMethodPool(Sel);
8907 Results.EnterNewScope();
8908 for (SemaObjC::GlobalMethodPool::iterator
8909 M =
SemaRef.ObjC().MethodPool.begin(),
8910 MEnd =
SemaRef.ObjC().MethodPool.end();
8918 Results.getCodeCompletionTUInfo());
8920 Builder.AddTypedTextChunk(
8922 Results.AddResult(Builder.TakeString());
8926 std::string Accumulator;
8927 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
8928 if (I == SelIdents.size()) {
8929 if (!Accumulator.empty()) {
8930 Builder.AddInformativeChunk(
8931 Builder.getAllocator().CopyString(Accumulator));
8932 Accumulator.clear();
8939 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
8940 Results.AddResult(Builder.TakeString());
8942 Results.ExitScope();
8945 Results.getCompletionContext(), Results.data(),
8952 bool OnlyForwardDeclarations,
8953 ResultBuilder &Results) {
8956 for (
const auto *D : Ctx->
decls()) {
8958 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
8959 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
8960 Results.AddResult(
Result(Proto, Results.getBasePriority(Proto),
8962 CurContext,
nullptr,
false);
8973 Results.EnterNewScope();
8980 Pair.getIdentifierInfo(), Pair.getLoc()))
8981 Results.Ignore(Protocol);
8985 SemaRef.CurContext,
false, Results);
8987 Results.ExitScope();
8991 Results.getCompletionContext(), Results.data(),
9001 Results.EnterNewScope();
9005 SemaRef.CurContext,
true, Results);
9007 Results.ExitScope();
9011 Results.getCompletionContext(), Results.data(),
9018 bool OnlyForwardDeclarations,
9019 bool OnlyUnimplemented,
9020 ResultBuilder &Results) {
9023 for (
const auto *D : Ctx->
decls()) {
9025 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
9026 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
9027 (!OnlyUnimplemented || !Class->getImplementation()))
9028 Results.AddResult(
Result(Class, Results.getBasePriority(Class),
9030 CurContext,
nullptr,
false);
9038 Results.EnterNewScope();
9043 SemaRef.CurContext,
false,
false, Results);
9046 Results.ExitScope();
9049 Results.getCompletionContext(), Results.data(),
9057 Results.EnterNewScope();
9062 SemaRef.CurContext,
false,
false, Results);
9065 Results.ExitScope();
9068 Results.getCompletionContext(), Results.data(),
9077 Results.EnterNewScope();
9083 Results.Ignore(CurClass);
9088 SemaRef.CurContext,
false,
false, Results);
9091 Results.ExitScope();
9094 Results.getCompletionContext(), Results.data(),
9102 Results.EnterNewScope();
9107 SemaRef.CurContext,
false,
true, Results);
9110 Results.ExitScope();
9113 Results.getCompletionContext(), Results.data(),
9131 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
9132 for (
const auto *Cat :
Class->visible_categories())
9133 CategoryNames.insert(Cat->getIdentifier());
9137 Results.EnterNewScope();
9139 for (
const auto *D : TU->
decls())
9140 if (
const auto *Category = dyn_cast<ObjCCategoryDecl>(D))
9141 if (CategoryNames.insert(Category->getIdentifier()).second)
9142 Results.AddResult(
Result(Category, Results.getBasePriority(Category),
9144 SemaRef.CurContext,
nullptr,
false);
9145 Results.ExitScope();
9148 Results.getCompletionContext(), Results.data(),
9173 Results.EnterNewScope();
9174 bool IgnoreImplemented =
true;
9176 for (
const auto *Cat :
Class->visible_categories()) {
9177 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
9178 CategoryNames.insert(Cat->getIdentifier()).second)
9179 Results.AddResult(
Result(Cat, Results.getBasePriority(Cat),
9181 SemaRef.CurContext,
nullptr,
false);
9185 IgnoreImplemented =
false;
9187 Results.ExitScope();
9190 Results.getCompletionContext(), Results.data(),
9201 dyn_cast_or_null<ObjCContainerDecl>(
SemaRef.CurContext);
9208 for (
const auto *D : Container->
decls())
9209 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
9210 Results.Ignore(PropertyImpl->getPropertyDecl());
9214 Results.EnterNewScope();
9216 dyn_cast<ObjCImplementationDecl>(Container))
9219 AddedProperties, Results);
9223 false,
false,
SemaRef.CurContext,
9224 AddedProperties, Results);
9225 Results.ExitScope();
9228 Results.getCompletionContext(), Results.data(),
9241 dyn_cast_or_null<ObjCContainerDecl>(
SemaRef.CurContext);
9249 dyn_cast<ObjCImplementationDecl>(Container))
9250 Class = ClassImpl->getClassInterface();
9254 ->getClassInterface();
9262 Property->getType().getNonReferenceType().getUnqualifiedType();
9265 Results.setPreferredType(PropertyType);
9270 Results.EnterNewScope();
9271 bool SawSimilarlyNamedIvar =
false;
9272 std::string NameWithPrefix;
9273 NameWithPrefix +=
'_';
9274 NameWithPrefix += PropertyName->getName();
9275 std::string NameWithSuffix = PropertyName->getName().str();
9276 NameWithSuffix +=
'_';
9279 Ivar = Ivar->getNextIvar()) {
9280 Results.AddResult(
Result(Ivar, Results.getBasePriority(Ivar),
9282 SemaRef.CurContext,
nullptr,
false);
9286 if ((PropertyName == Ivar->getIdentifier() ||
9287 NameWithPrefix == Ivar->getName() ||
9288 NameWithSuffix == Ivar->getName())) {
9289 SawSimilarlyNamedIvar =
true;
9293 if (Results.size() &&
9294 Results.data()[Results.size() - 1].Kind ==
9296 Results.data()[Results.size() - 1].Declaration == Ivar)
9297 Results.data()[Results.size() - 1].Priority--;
9302 if (!SawSimilarlyNamedIvar) {
9314 Builder.AddTypedTextChunk(Allocator.
CopyString(NameWithPrefix));
9319 Results.ExitScope();
9322 Results.getCompletionContext(), Results.data(),
9329 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
9338 std::optional<bool> WantInstanceMethods,
9341 bool InOriginalClass =
true) {
9344 if (!IFace->hasDefinition())
9347 IFace = IFace->getDefinition();
9351 IFace->getReferencedProtocols();
9353 E = Protocols.
end();
9356 KnownMethods, InOriginalClass);
9359 for (
auto *Cat : IFace->visible_categories()) {
9361 KnownMethods,
false);
9365 if (IFace->getSuperClass())
9367 WantInstanceMethods, ReturnType, KnownMethods,
9374 Category->getReferencedProtocols();
9376 E = Protocols.
end();
9379 KnownMethods, InOriginalClass);
9382 if (InOriginalClass && Category->getClassInterface())
9384 WantInstanceMethods, ReturnType, KnownMethods,
9390 if (!Protocol->hasDefinition())
9392 Protocol = Protocol->getDefinition();
9393 Container = Protocol;
9397 Protocol->getReferencedProtocols();
9399 E = Protocols.
end();
9402 KnownMethods,
false);
9408 for (
auto *M : Container->
methods()) {
9409 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
9410 if (!ReturnType.
isNull() &&
9411 !Context.hasSameUnqualifiedType(ReturnType, M->getReturnType()))
9414 KnownMethods[M->getSelector()] =
9415 KnownMethodsMap::mapped_type(M, InOriginalClass);
9429 Builder.AddTextChunk(Builder.getAllocator().CopyString(Quals));
9430 Builder.AddTextChunk(
9441 if (Class->getIdentifier() && Class->getIdentifier()->getName() == Name)
9450 bool IsInstanceMethod,
9453 ResultBuilder &Results) {
9455 if (!PropName || PropName->
getLength() == 0)
9473 const char *CopiedKey;
9476 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
9478 operator const char *() {
9482 return CopiedKey = Allocator.
CopyString(Key);
9484 } Key(Allocator, PropName->
getName());
9487 std::string UpperKey = std::string(PropName->
getName());
9488 if (!UpperKey.empty())
9491 bool ReturnTypeMatchesProperty =
9494 Property->getType());
9495 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
9498 if (IsInstanceMethod &&
9500 ReturnTypeMatchesProperty && !Property->getGetterMethodDecl()) {
9505 Builder.AddTypedTextChunk(Key);
9512 if (IsInstanceMethod &&
9513 ((!ReturnType.
isNull() &&
9515 (ReturnType.
isNull() && (Property->getType()->isIntegerType() ||
9516 Property->getType()->isBooleanType())))) {
9517 std::string SelectorName = (Twine(
"is") + UpperKey).str();
9521 if (ReturnType.
isNull()) {
9523 Builder.AddTextChunk(
"BOOL");
9534 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
9535 !Property->getSetterMethodDecl()) {
9536 std::string SelectorName = (Twine(
"set") + UpperKey).str();
9538 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9539 if (ReturnType.
isNull()) {
9541 Builder.AddTextChunk(
"void");
9545 Builder.AddTypedTextChunk(
9549 Builder.AddTextChunk(Key);
9560 if (
const auto *ObjCPointer =
9585 if (IsInstanceMethod &&
9587 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
9591 if (ReturnType.
isNull()) {
9593 Builder.AddTextChunk(
"NSUInteger");
9599 Result(Builder.TakeString(),
9600 std::min(IndexedGetterPriority, UnorderedGetterPriority),
9607 if (IsInstanceMethod &&
9609 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
9611 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9612 if (ReturnType.
isNull()) {
9614 Builder.AddTextChunk(
"id");
9618 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9620 Builder.AddTextChunk(
"NSUInteger");
9622 Builder.AddTextChunk(
"index");
9623 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9629 if (IsInstanceMethod &&
9636 std::string SelectorName = (Twine(Property->getName()) +
"AtIndexes").str();
9638 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9639 if (ReturnType.
isNull()) {
9641 Builder.AddTextChunk(
"NSArray *");
9645 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9647 Builder.AddTextChunk(
"NSIndexSet *");
9649 Builder.AddTextChunk(
"indexes");
9650 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9656 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9657 std::string SelectorName = (Twine(
"get") + UpperKey).str();
9658 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName),
9659 &Context.Idents.get(
"range")};
9661 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9662 if (ReturnType.
isNull()) {
9664 Builder.AddTextChunk(
"void");
9668 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9670 Builder.AddPlaceholderChunk(
"object-type");
9671 Builder.AddTextChunk(
" **");
9673 Builder.AddTextChunk(
"buffer");
9675 Builder.AddTypedTextChunk(
"range:");
9677 Builder.AddTextChunk(
"NSRange");
9679 Builder.AddTextChunk(
"inRange");
9680 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9688 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9689 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
9690 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(
"insertObject"),
9691 &Context.Idents.get(SelectorName)};
9693 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9694 if (ReturnType.
isNull()) {
9696 Builder.AddTextChunk(
"void");
9700 Builder.AddTypedTextChunk(
"insertObject:");
9702 Builder.AddPlaceholderChunk(
"object-type");
9703 Builder.AddTextChunk(
" *");
9705 Builder.AddTextChunk(
"object");
9707 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9709 Builder.AddPlaceholderChunk(
"NSUInteger");
9711 Builder.AddTextChunk(
"index");
9712 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9718 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9719 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
9720 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName),
9721 &Context.Idents.get(
"atIndexes")};
9723 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9724 if (ReturnType.
isNull()) {
9726 Builder.AddTextChunk(
"void");
9730 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9732 Builder.AddTextChunk(
"NSArray *");
9734 Builder.AddTextChunk(
"array");
9736 Builder.AddTypedTextChunk(
"atIndexes:");
9738 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9740 Builder.AddTextChunk(
"indexes");
9741 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9747 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9748 std::string SelectorName =
9749 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
9750 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9751 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9752 if (ReturnType.
isNull()) {
9754 Builder.AddTextChunk(
"void");
9758 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9760 Builder.AddTextChunk(
"NSUInteger");
9762 Builder.AddTextChunk(
"index");
9763 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9769 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9770 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
9771 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9772 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9773 if (ReturnType.
isNull()) {
9775 Builder.AddTextChunk(
"void");
9779 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9781 Builder.AddTextChunk(
"NSIndexSet *");
9783 Builder.AddTextChunk(
"indexes");
9784 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9790 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9791 std::string SelectorName =
9792 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
9793 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName),
9794 &Context.Idents.get(
"withObject")};
9796 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9797 if (ReturnType.
isNull()) {
9799 Builder.AddTextChunk(
"void");
9803 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9805 Builder.AddPlaceholderChunk(
"NSUInteger");
9807 Builder.AddTextChunk(
"index");
9809 Builder.AddTypedTextChunk(
"withObject:");
9811 Builder.AddTextChunk(
"id");
9813 Builder.AddTextChunk(
"object");
9814 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9820 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9821 std::string SelectorName1 =
9822 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
9823 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
9824 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName1),
9825 &Context.Idents.get(SelectorName2)};
9827 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9828 if (ReturnType.
isNull()) {
9830 Builder.AddTextChunk(
"void");
9834 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName1 +
":"));
9836 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9838 Builder.AddTextChunk(
"indexes");
9840 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName2 +
":"));
9842 Builder.AddTextChunk(
"NSArray *");
9844 Builder.AddTextChunk(
"array");
9845 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9852 if (IsInstanceMethod &&
9858 ->
getName() ==
"NSEnumerator"))) {
9859 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
9860 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9863 if (ReturnType.
isNull()) {
9865 Builder.AddTextChunk(
"NSEnumerator *");
9869 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
9870 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9876 if (IsInstanceMethod &&
9878 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
9879 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9880 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9881 if (ReturnType.
isNull()) {
9883 Builder.AddPlaceholderChunk(
"object-type");
9884 Builder.AddTextChunk(
" *");
9888 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9890 if (ReturnType.
isNull()) {
9891 Builder.AddPlaceholderChunk(
"object-type");
9892 Builder.AddTextChunk(
" *");
9895 ReturnType, Context, Policy, Builder.getAllocator()));
9898 Builder.AddTextChunk(
"object");
9899 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9906 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9907 std::string SelectorName =
9908 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
9909 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9910 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9911 if (ReturnType.
isNull()) {
9913 Builder.AddTextChunk(
"void");
9917 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9919 Builder.AddPlaceholderChunk(
"object-type");
9920 Builder.AddTextChunk(
" *");
9922 Builder.AddTextChunk(
"object");
9923 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9929 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9930 std::string SelectorName = (Twine(
"add") + UpperKey).str();
9931 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9932 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9933 if (ReturnType.
isNull()) {
9935 Builder.AddTextChunk(
"void");
9939 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9941 Builder.AddTextChunk(
"NSSet *");
9943 Builder.AddTextChunk(
"objects");
9944 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9950 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9951 std::string SelectorName =
9952 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
9953 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9954 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9955 if (ReturnType.
isNull()) {
9957 Builder.AddTextChunk(
"void");
9961 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9963 Builder.AddPlaceholderChunk(
"object-type");
9964 Builder.AddTextChunk(
" *");
9966 Builder.AddTextChunk(
"object");
9967 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9973 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9974 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
9975 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9976 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9977 if (ReturnType.
isNull()) {
9979 Builder.AddTextChunk(
"void");
9983 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9985 Builder.AddTextChunk(
"NSSet *");
9987 Builder.AddTextChunk(
"objects");
9988 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9994 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9995 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
9996 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9997 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9998 if (ReturnType.
isNull()) {
10000 Builder.AddTextChunk(
"void");
10004 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
10006 Builder.AddTextChunk(
"NSSet *");
10008 Builder.AddTextChunk(
"objects");
10009 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
10016 if (!IsInstanceMethod &&
10023 std::string SelectorName =
10024 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
10025 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
10028 if (ReturnType.
isNull()) {
10030 Builder.AddTextChunk(
"NSSet<NSString *> *");
10034 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
10041 if (!IsInstanceMethod &&
10044 std::string SelectorName =
10045 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
10046 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
10049 if (ReturnType.
isNull()) {
10051 Builder.AddTextChunk(
"BOOL");
10055 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
10063 Scope *S, std::optional<bool> IsInstanceMethod,
ParsedType ReturnTy) {
10068 Decl *IDecl =
nullptr;
10069 if (
SemaRef.CurContext->isObjCContainer()) {
10075 bool IsInImplementation =
false;
10076 if (
Decl *D = IDecl) {
10078 SearchDecl = Impl->getClassInterface();
10079 IsInImplementation =
true;
10081 dyn_cast<ObjCCategoryImplDecl>(D)) {
10082 SearchDecl = CatImpl->getCategoryDecl();
10083 IsInImplementation =
true;
10085 SearchDecl = dyn_cast<ObjCContainerDecl>(D);
10088 if (!SearchDecl && S) {
10090 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
10109 Results.EnterNewScope();
10111 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
10112 MEnd = KnownMethods.end();
10116 Results.getCodeCompletionTUInfo());
10119 if (!IsInstanceMethod) {
10120 Builder.AddTextChunk(
Method->isInstanceMethod() ?
"-" :
"+");
10126 if (ReturnType.
isNull()) {
10127 QualType ResTy =
Method->getSendResultType().stripObjCKindOfType(Context);
10128 AttributedType::stripOuterNullability(ResTy);
10137 Builder.AddTypedTextChunk(
10143 PEnd =
Method->param_end();
10144 P != PEnd; (
void)++P, ++I) {
10147 Builder.AddTypedTextChunk(
10148 Builder.getAllocator().CopyString(Sel.
getNameForSlot(I) +
":"));
10151 Builder.AddTypedTextChunk(
10152 Builder.getAllocator().CopyString(Sel.
getNameForSlot(I) +
":"));
10159 ParamType = (*P)->getType();
10161 ParamType = (*P)->getOriginalType();
10164 AttributedType::stripOuterNullability(ParamType);
10166 Context, Policy, Builder);
10169 Builder.AddTextChunk(
10170 Builder.getAllocator().CopyString(Id->getName()));
10174 if (
Method->isVariadic()) {
10175 if (
Method->param_size() > 0)
10177 Builder.AddTextChunk(
"...");
10180 if (IsInImplementation && Results.includeCodePatterns()) {
10185 if (!
Method->getReturnType()->isVoidType()) {
10187 Builder.AddTextChunk(
"return");
10189 Builder.AddPlaceholderChunk(
"expression");
10192 Builder.AddPlaceholderChunk(
"statements");
10199 auto R =
Result(Builder.TakeString(),
Method, Priority);
10200 if (!M->second.getInt())
10202 Results.AddResult(std::move(R));
10207 if (Context.getLangOpts().ObjC) {
10209 Containers.push_back(SearchDecl);
10212 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
10213 MEnd = KnownMethods.end();
10215 KnownSelectors.insert(M->first);
10220 IFace = Category->getClassInterface();
10225 if (IsInstanceMethod) {
10226 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
10227 for (
auto *P : Containers[I]->instance_properties())
10229 KnownSelectors, Results);
10233 Results.ExitScope();
10236 Results.getCompletionContext(), Results.data(),
10241 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
10245 if (
SemaRef.ExternalSource) {
10246 for (uint32_t I = 0, N =
SemaRef.ExternalSource->GetNumExternalSelectors();
10252 SemaRef.ObjC().ReadMethodPool(Sel);
10263 Results.setPreferredType(
10264 SemaRef.GetTypeFromParser(ReturnTy).getNonReferenceType());
10266 Results.EnterNewScope();
10267 for (SemaObjC::GlobalMethodPool::iterator
10268 M =
SemaRef.ObjC().MethodPool.begin(),
10269 MEnd =
SemaRef.ObjC().MethodPool.end();
10271 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
10272 : &M->second.second;
10273 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
10277 if (AtParameterName) {
10279 unsigned NumSelIdents = SelIdents.size();
10280 if (NumSelIdents &&
10281 NumSelIdents <= MethList->getMethod()->param_size()) {
10283 MethList->getMethod()->parameters()[NumSelIdents - 1];
10284 if (Param->getIdentifier()) {
10286 Results.getCodeCompletionTUInfo());
10287 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
10288 Param->getIdentifier()->getName()));
10289 Results.AddResult(Builder.TakeString());
10296 Result R(MethList->getMethod(),
10297 Results.getBasePriority(MethList->getMethod()),
10299 R.StartParameter = SelIdents.size();
10300 R.AllParametersAreInformative =
false;
10301 R.DeclaringEntity =
true;
10302 Results.MaybeAddResult(R,
SemaRef.CurContext);
10306 Results.ExitScope();
10308 if (!AtParameterName && !SelIdents.empty() &&
10309 SelIdents.front()->getName().starts_with(
"init")) {
10310 for (
const auto &M :
SemaRef.PP.macros()) {
10311 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
10313 Results.EnterNewScope();
10315 Results.getCodeCompletionTUInfo());
10316 Builder.AddTypedTextChunk(
10317 Builder.getAllocator().CopyString(M.first->getName()));
10320 Results.ExitScope();
10325 Results.getCompletionContext(), Results.data(),
10333 Results.EnterNewScope();
10337 Results.getCodeCompletionTUInfo());
10338 Builder.AddTypedTextChunk(
"if");
10340 Builder.AddPlaceholderChunk(
"condition");
10341 Results.AddResult(Builder.TakeString());
10344 Builder.AddTypedTextChunk(
"ifdef");
10346 Builder.AddPlaceholderChunk(
"macro");
10347 Results.AddResult(Builder.TakeString());
10350 Builder.AddTypedTextChunk(
"ifndef");
10352 Builder.AddPlaceholderChunk(
"macro");
10353 Results.AddResult(Builder.TakeString());
10355 if (InConditional) {
10357 Builder.AddTypedTextChunk(
"elif");
10359 Builder.AddPlaceholderChunk(
"condition");
10360 Results.AddResult(Builder.TakeString());
10363 Builder.AddTypedTextChunk(
"elifdef");
10365 Builder.AddPlaceholderChunk(
"macro");
10366 Results.AddResult(Builder.TakeString());
10369 Builder.AddTypedTextChunk(
"elifndef");
10371 Builder.AddPlaceholderChunk(
"macro");
10372 Results.AddResult(Builder.TakeString());
10375 Builder.AddTypedTextChunk(
"else");
10376 Results.AddResult(Builder.TakeString());
10379 Builder.AddTypedTextChunk(
"endif");
10380 Results.AddResult(Builder.TakeString());
10384 Builder.AddTypedTextChunk(
"include");
10386 Builder.AddTextChunk(
"\"");
10387 Builder.AddPlaceholderChunk(
"header");
10388 Builder.AddTextChunk(
"\"");
10389 Results.AddResult(Builder.TakeString());
10392 Builder.AddTypedTextChunk(
"include");
10394 Builder.AddTextChunk(
"<");
10395 Builder.AddPlaceholderChunk(
"header");
10396 Builder.AddTextChunk(
">");
10397 Results.AddResult(Builder.TakeString());
10400 Builder.AddTypedTextChunk(
"define");
10402 Builder.AddPlaceholderChunk(
"macro");
10403 Results.AddResult(Builder.TakeString());
10406 Builder.AddTypedTextChunk(
"define");
10408 Builder.AddPlaceholderChunk(
"macro");
10410 Builder.AddPlaceholderChunk(
"args");
10412 Results.AddResult(Builder.TakeString());
10415 Builder.AddTypedTextChunk(
"undef");
10417 Builder.AddPlaceholderChunk(
"macro");
10418 Results.AddResult(Builder.TakeString());
10421 Builder.AddTypedTextChunk(
"line");
10423 Builder.AddPlaceholderChunk(
"number");
10424 Results.AddResult(Builder.TakeString());
10427 Builder.AddTypedTextChunk(
"line");
10429 Builder.AddPlaceholderChunk(
"number");
10431 Builder.AddTextChunk(
"\"");
10432 Builder.AddPlaceholderChunk(
"filename");
10433 Builder.AddTextChunk(
"\"");
10434 Results.AddResult(Builder.TakeString());
10437 Builder.AddTypedTextChunk(
"error");
10439 Builder.AddPlaceholderChunk(
"message");
10440 Results.AddResult(Builder.TakeString());
10443 Builder.AddTypedTextChunk(
"pragma");
10445 Builder.AddPlaceholderChunk(
"arguments");
10446 Results.AddResult(Builder.TakeString());
10450 Builder.AddTypedTextChunk(
"import");
10452 Builder.AddTextChunk(
"\"");
10453 Builder.AddPlaceholderChunk(
"header");
10454 Builder.AddTextChunk(
"\"");
10455 Results.AddResult(Builder.TakeString());
10458 Builder.AddTypedTextChunk(
"import");
10460 Builder.AddTextChunk(
"<");
10461 Builder.AddPlaceholderChunk(
"header");
10462 Builder.AddTextChunk(
">");
10463 Results.AddResult(Builder.TakeString());
10467 Builder.AddTypedTextChunk(
"include_next");
10469 Builder.AddTextChunk(
"\"");
10470 Builder.AddPlaceholderChunk(
"header");
10471 Builder.AddTextChunk(
"\"");
10472 Results.AddResult(Builder.TakeString());
10475 Builder.AddTypedTextChunk(
"include_next");
10477 Builder.AddTextChunk(
"<");
10478 Builder.AddPlaceholderChunk(
"header");
10479 Builder.AddTextChunk(
">");
10480 Results.AddResult(Builder.TakeString());
10483 Builder.AddTypedTextChunk(
"warning");
10485 Builder.AddPlaceholderChunk(
"message");
10486 Results.AddResult(Builder.TakeString());
10490 Builder.AddTypedTextChunk(
"embed");
10492 Builder.AddTextChunk(
"\"");
10493 Builder.AddPlaceholderChunk(
"file");
10494 Builder.AddTextChunk(
"\"");
10495 Results.AddResult(Builder.TakeString());
10498 Builder.AddTypedTextChunk(
"embed");
10500 Builder.AddTextChunk(
"<");
10501 Builder.AddPlaceholderChunk(
"file");
10502 Builder.AddTextChunk(
">");
10503 Results.AddResult(Builder.TakeString());
10511 Results.ExitScope();
10514 Results.getCompletionContext(), Results.data(),
10533 Results.getCodeCompletionTUInfo());
10534 Results.EnterNewScope();
10535 for (
const auto &M :
SemaRef.PP.macros()) {
10536 Builder.AddTypedTextChunk(
10537 Builder.getAllocator().CopyString(M.first->getName()));
10541 Results.ExitScope();
10542 }
else if (IsDefinition) {
10547 Results.getCompletionContext(), Results.data(),
10560 Results.EnterNewScope();
10562 Results.getCodeCompletionTUInfo());
10563 Builder.AddTypedTextChunk(
"defined");
10566 Builder.AddPlaceholderChunk(
"macro");
10568 Results.AddResult(Builder.TakeString());
10569 Results.ExitScope();
10572 Results.getCompletionContext(), Results.data(),
10592 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
10595 llvm::sys::path::native(NativeRelDir);
10596 llvm::vfs::FileSystem &FS =
10597 SemaRef.getSourceManager().getFileManager().getVirtualFileSystem();
10602 llvm::DenseSet<StringRef> SeenResults;
10605 auto AddCompletion = [&](StringRef Filename,
bool IsDirectory) {
10608 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
10609 auto R = SeenResults.insert(TypedChunk);
10611 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
10612 *R.first = InternedTyped;
10615 Builder.AddTypedTextChunk(InternedTyped);
10623 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
10627 if (!NativeRelDir.empty()) {
10631 auto Begin = llvm::sys::path::begin(NativeRelDir);
10632 auto End = llvm::sys::path::end(NativeRelDir);
10634 llvm::sys::path::append(Dir, *Begin +
".framework",
"Headers");
10635 llvm::sys::path::append(Dir, ++Begin, End);
10637 llvm::sys::path::append(Dir, NativeRelDir);
10641 const StringRef &Dirname = llvm::sys::path::filename(Dir);
10642 const bool isQt = Dirname.starts_with(
"Qt") || Dirname ==
"ActiveQt";
10643 const bool ExtensionlessHeaders =
10644 IsSystem || isQt || Dir.ends_with(
".framework/Headers") ||
10645 IncludeDir.ends_with(
"/include") || IncludeDir.ends_with(
"\\include");
10646 std::error_code EC;
10647 unsigned Count = 0;
10648 for (
auto It = FS.dir_begin(Dir, EC);
10649 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
10650 if (++Count == 2500)
10652 StringRef Filename = llvm::sys::path::filename(It->path());
10657 llvm::sys::fs::file_type
Type = It->type();
10658 if (
Type == llvm::sys::fs::file_type::symlink_file) {
10659 if (
auto FileStatus = FS.status(It->path()))
10660 Type = FileStatus->getType();
10663 case llvm::sys::fs::file_type::directory_file:
10667 NativeRelDir.empty() && !Filename.consume_back(
".framework"))
10670 AddCompletion(Filename,
true);
10672 case llvm::sys::fs::file_type::regular_file: {
10674 const bool IsHeader = Filename.ends_with_insensitive(
".h") ||
10675 Filename.ends_with_insensitive(
".hh") ||
10676 Filename.ends_with_insensitive(
".hpp") ||
10677 Filename.ends_with_insensitive(
".hxx") ||
10678 Filename.ends_with_insensitive(
".inc") ||
10679 (ExtensionlessHeaders && !Filename.contains(
'.'));
10682 AddCompletion(Filename,
false);
10694 switch (IncludeDir.getLookupType()) {
10699 AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
10703 AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
10712 const auto &S =
SemaRef.PP.getHeaderSearchInfo();
10713 using llvm::make_range;
10716 if (
auto CurFile =
SemaRef.PP.getCurrentFileLexer()->getFileEntry())
10717 AddFilesFromIncludeDir(CurFile->getDir().getName(),
false,
10719 for (
const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
10720 AddFilesFromDirLookup(D,
false);
10722 for (
const auto &D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
10723 AddFilesFromDirLookup(D,
false);
10724 for (
const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
10725 AddFilesFromDirLookup(D,
true);
10728 Results.getCompletionContext(), Results.data(),
10742 Results.EnterNewScope();
10743 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
10747 Twine(Platform) +
"ApplicationExtension")));
10749 Results.ExitScope();
10751 Results.getCompletionContext(), Results.data(),
10758 ResultBuilder Builder(
SemaRef, Allocator, CCTUInfo,
10761 CodeCompletionDeclConsumer Consumer(
10773 Results.insert(Results.end(), Builder.data(),
10774 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