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/StringSwitch.h"
54#include "llvm/ADT/Twine.h"
55#include "llvm/ADT/iterator_range.h"
56#include "llvm/Support/Casting.h"
57#include "llvm/Support/Path.h"
58#include "llvm/Support/raw_ostream.h"
77 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
79 typedef CodeCompletionResult Result;
83 std::vector<Result> Results;
88 llvm::SmallPtrSet<const Decl *, 16> AllDeclsFound;
90 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
95 class ShadowMapEntry {
96 typedef SmallVector<DeclIndexPair, 4> DeclIndexPairVector;
100 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector *> DeclOrVector;
104 unsigned SingleDeclIndex = 0;
107 ShadowMapEntry() =
default;
108 ShadowMapEntry(
const ShadowMapEntry &) =
delete;
109 ShadowMapEntry(ShadowMapEntry &&Move) { *
this = std::move(Move); }
110 ShadowMapEntry &operator=(
const ShadowMapEntry &) =
delete;
111 ShadowMapEntry &operator=(ShadowMapEntry &&Move) {
112 SingleDeclIndex =
Move.SingleDeclIndex;
113 DeclOrVector =
Move.DeclOrVector;
114 Move.DeclOrVector =
nullptr;
118 void Add(
const NamedDecl *ND,
unsigned Index) {
119 if (DeclOrVector.isNull()) {
122 SingleDeclIndex = Index;
126 if (
const NamedDecl *PrevND = dyn_cast<const NamedDecl *>(DeclOrVector)) {
129 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
130 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
136 ->push_back(DeclIndexPair(ND, Index));
140 if (DeclIndexPairVector *Vec =
141 dyn_cast_if_present<DeclIndexPairVector *>(DeclOrVector)) {
143 DeclOrVector = ((NamedDecl *)
nullptr);
156 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
163 CodeCompletionAllocator &Allocator;
165 CodeCompletionTUInfo &CCTUInfo;
173 bool AllowNestedNameSpecifiers;
184 std::list<ShadowMap> ShadowMaps;
188 llvm::DenseMap<std::pair<DeclContext *,
uintptr_t>, ShadowMapEntry>
193 Qualifiers ObjectTypeQualifiers;
198 bool HasObjectTypeQualifiers;
201 bool IsExplicitObjectMemberFunction;
204 Selector PreferredSelector;
207 CodeCompletionContext CompletionContext;
211 ObjCImplementationDecl *ObjCImplementation;
213 void AdjustResultPriorityForDecl(Result &R);
215 void MaybeAddConstructorResults(Result R);
218 explicit ResultBuilder(Sema &SemaRef, CodeCompletionAllocator &Allocator,
219 CodeCompletionTUInfo &CCTUInfo,
220 const CodeCompletionContext &CompletionContext,
221 LookupFilter Filter =
nullptr)
222 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
223 Filter(Filter), AllowNestedNameSpecifiers(
false),
224 HasObjectTypeQualifiers(
false), IsExplicitObjectMemberFunction(
false),
225 CompletionContext(CompletionContext), ObjCImplementation(
nullptr) {
228 switch (CompletionContext.getKind()) {
229 case CodeCompletionContext::CCC_Expression:
230 case CodeCompletionContext::CCC_ObjCMessageReceiver:
231 case CodeCompletionContext::CCC_ParenthesizedExpression:
232 case CodeCompletionContext::CCC_Statement:
233 case CodeCompletionContext::CCC_TopLevelOrExpression:
234 case CodeCompletionContext::CCC_Recovery:
235 if (ObjCMethodDecl *Method = SemaRef.getCurMethodDecl())
236 if (Method->isInstanceMethod())
237 if (ObjCInterfaceDecl *Interface = Method->getClassInterface())
238 ObjCImplementation = Interface->getImplementation();
247 unsigned getBasePriority(
const NamedDecl *D);
251 bool includeCodePatterns()
const {
252 return SemaRef.CodeCompletion().CodeCompleter &&
253 SemaRef.CodeCompletion().CodeCompleter->includeCodePatterns();
257 void setFilter(LookupFilter Filter) { this->Filter = Filter; }
259 Result *data() {
return Results.empty() ?
nullptr : &Results.front(); }
260 unsigned size()
const {
return Results.size(); }
261 bool empty()
const {
return Results.empty(); }
264 void setPreferredType(QualType
T) {
265 PreferredType = SemaRef.Context.getCanonicalType(
T);
275 void setObjectTypeQualifiers(Qualifiers Quals,
ExprValueKind Kind) {
276 ObjectTypeQualifiers = Quals;
278 HasObjectTypeQualifiers =
true;
281 void setExplicitObjectMemberFn(
bool IsExplicitObjectFn) {
282 IsExplicitObjectMemberFunction = IsExplicitObjectFn;
290 void setPreferredSelector(Selector Sel) { PreferredSelector = Sel; }
294 const CodeCompletionContext &getCompletionContext()
const {
295 return CompletionContext;
299 void allowNestedNameSpecifiers(
bool Allow =
true) {
300 AllowNestedNameSpecifiers =
Allow;
305 Sema &getSema()
const {
return SemaRef; }
308 CodeCompletionAllocator &getAllocator()
const {
return Allocator; }
310 CodeCompletionTUInfo &getCodeCompletionTUInfo()
const {
return CCTUInfo; }
319 bool isInterestingDecl(
const NamedDecl *ND,
320 bool &AsNestedNameSpecifier)
const;
328 bool canFunctionBeCalled(
const NamedDecl *ND, QualType BaseExprType)
const;
336 bool canCxxMethodBeCalled(
const CXXMethodDecl *
Method,
337 QualType BaseExprType)
const;
345 bool CheckHiddenResult(Result &R, DeclContext *CurContext,
346 const NamedDecl *Hiding);
355 void MaybeAddResult(Result R, DeclContext *CurContext =
nullptr);
371 void AddResult(Result R, DeclContext *CurContext, NamedDecl *Hiding,
372 bool InBaseClass, QualType BaseExprType,
373 bool IsInDeclarationContext,
bool IsAddressOfOperand);
376 void AddResult(Result R);
379 void EnterNewScope();
388 void addVisitedContext(DeclContext *Ctx) {
389 CompletionContext.addVisitedContext(Ctx);
398 bool IsOrdinaryName(
const NamedDecl *ND)
const;
399 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
400 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
401 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
402 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
403 bool IsEnum(
const NamedDecl *ND)
const;
404 bool IsClassOrStruct(
const NamedDecl *ND)
const;
405 bool IsUnion(
const NamedDecl *ND)
const;
406 bool IsNamespace(
const NamedDecl *ND)
const;
407 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
408 bool IsType(
const NamedDecl *ND)
const;
409 bool IsMember(
const NamedDecl *ND)
const;
410 bool IsOffsetofField(
const NamedDecl *ND)
const;
411 bool IsObjCIvar(
const NamedDecl *ND)
const;
412 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
413 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
414 bool IsObjCCollection(
const NamedDecl *ND)
const;
415 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
428 for (
auto *Redecl : Function->getFirstDecl()->redecls()) {
432 if (Redecl->getNumParams() < ParaCount)
434 for (
unsigned P = Start, N = Redecl->getNumParams(); P != N; ++P)
435 if (Redecl->getParamDecl(P)->getIdentifier())
447 ComputeType =
nullptr;
448 Type = BSI->ReturnType;
452 ComputeType =
nullptr;
456 ComputeType =
nullptr;
457 Type =
Method->getReturnType();
465 auto *VD = llvm::dyn_cast_or_null<ValueDecl>(D);
466 ComputeType =
nullptr;
467 Type = VD ? VD->getType() :
QualType();
483 ComputeType =
nullptr;
493 this->ComputeType = ComputeType;
503 if (ExpectedLoc == LParLoc)
514 if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
517 if (Op == tok::minus)
530 case tok::minusequal:
532 case tok::percentequal:
534 case tok::slashequal:
540 case tok::equalequal:
541 case tok::exclaimequal:
545 case tok::greaterequal:
549 case tok::greatergreater:
550 case tok::greatergreaterequal:
552 case tok::lesslessequal:
565 case tok::caretequal:
573 case tok::periodstar:
591 if (!ContextType.isNull() && ContextType->isPointerType())
592 return ContextType->getPointeeType();
595 if (ContextType.isNull())
601 case tok::minusminus:
603 if (ContextType.isNull())
611 assert(
false &&
"unhandled unary op");
620 ComputeType =
nullptr;
627 if (!Enabled || !
Base)
630 if (ExpectedLoc !=
Base->getBeginLoc())
641 ComputeType =
nullptr;
650 ComputeType =
nullptr;
659 ComputeType =
nullptr;
667 ComputeType =
nullptr;
673 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
674 unsigned SingleDeclIndex;
686 pointer(
const DeclIndexPair &Value) : Value(Value) {}
694 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) {}
697 : DeclOrIterator(Iterator), SingleDeclIndex(0) {}
719 if (
const NamedDecl *ND = dyn_cast<const NamedDecl *>(DeclOrIterator))
728 return X.DeclOrIterator.getOpaqueValue() ==
729 Y.DeclOrIterator.getOpaqueValue() &&
730 X.SingleDeclIndex == Y.SingleDeclIndex;
739ResultBuilder::ShadowMapEntry::begin()
const {
740 if (DeclOrVector.isNull())
743 if (
const NamedDecl *ND = dyn_cast<const NamedDecl *>(DeclOrVector))
744 return iterator(ND, SingleDeclIndex);
750ResultBuilder::ShadowMapEntry::end()
const {
775 for (
const DeclContext *CommonAncestor = TargetContext;
776 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
777 CommonAncestor = CommonAncestor->getLookupParent()) {
778 if (CommonAncestor->isTransparentContext() ||
779 CommonAncestor->isFunctionOrMethod())
782 TargetParents.push_back(CommonAncestor);
786 while (!TargetParents.empty()) {
787 const DeclContext *Parent = TargetParents.pop_back_val();
789 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
790 if (!Namespace->getIdentifier())
794 }
else if (
const auto *TD = dyn_cast<TagDecl>(Parent)) {
827bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
828 bool &AsNestedNameSpecifier)
const {
829 AsNestedNameSpecifier =
false;
855 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
857 Filter != &ResultBuilder::IsNamespaceOrAlias && Filter !=
nullptr))
858 AsNestedNameSpecifier =
true;
861 if (Filter && !(this->*Filter)(Named)) {
863 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
864 IsNestedNameSpecifier(ND) &&
865 (Filter != &ResultBuilder::IsMember ||
868 AsNestedNameSpecifier =
true;
887 R.Declaration->getDeclContext()->getRedeclContext();
898 R.QualifierIsInformative =
false;
902 R.Declaration->getDeclContext());
909 switch (
T->getTypeClass()) {
912 case BuiltinType::Void:
915 case BuiltinType::NullPtr:
918 case BuiltinType::Overload:
919 case BuiltinType::Dependent:
922 case BuiltinType::ObjCId:
923 case BuiltinType::ObjCClass:
924 case BuiltinType::ObjCSel:
937 case Type::BlockPointer:
940 case Type::LValueReference:
941 case Type::RValueReference:
944 case Type::ConstantArray:
945 case Type::IncompleteArray:
946 case Type::VariableArray:
947 case Type::DependentSizedArray:
950 case Type::DependentSizedExtVector:
952 case Type::ExtVector:
955 case Type::FunctionProto:
956 case Type::FunctionNoProto:
965 case Type::ObjCObject:
966 case Type::ObjCInterface:
967 case Type::ObjCObjectPointer:
981 if (
const auto *
Type = dyn_cast<TypeDecl>(ND))
983 if (
const auto *Iface = dyn_cast<ObjCInterfaceDecl>(ND))
984 return C.getObjCInterfaceType(Iface);
989 else if (
const auto *
Method = dyn_cast<ObjCMethodDecl>(ND))
990 T =
Method->getSendResultType();
991 else if (
const auto *
Enumerator = dyn_cast<EnumConstantDecl>(ND))
995 else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND))
997 else if (
const auto *
Value = dyn_cast<ValueDecl>(ND))
1008 T = Ref->getPointeeType();
1013 if (
Pointer->getPointeeType()->isFunctionType()) {
1022 T =
Block->getPointeeType();
1037unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
1045 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
1046 if (ImplicitParam->getIdentifier() &&
1047 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
1076 CompletionContext.
getKind() ==
1078 CompletionContext.
getKind() ==
1085void ResultBuilder::AdjustResultPriorityForDecl(
Result &R) {
1088 if (!PreferredSelector.
isNull())
1089 if (
const auto *
Method = dyn_cast<ObjCMethodDecl>(
R.Declaration))
1090 if (PreferredSelector ==
Method->getSelector())
1095 if (!PreferredType.
isNull()) {
1105 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
1115 Context.DeclarationNames.getCXXConstructorName(RecordTy);
1116 return Record->lookup(ConstructorName);
1119void ResultBuilder::MaybeAddConstructorResults(
Result R) {
1120 if (!SemaRef.
getLangOpts().CPlusPlus || !
R.Declaration ||
1127 Record = ClassTemplate->getTemplatedDecl();
1128 else if ((
Record = dyn_cast<CXXRecordDecl>(D))) {
1142 R.Declaration = Ctor;
1144 Results.push_back(R);
1149 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
1150 ND = Tmpl->getTemplatedDecl();
1155 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
1157 if (
R.Kind != Result::RK_Declaration) {
1159 Results.push_back(R);
1164 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(
R.Declaration)) {
1166 getBasePriority(
Using->getTargetDecl()),
1170 std::move(
R.FixIts));
1172 MaybeAddResult(
Result, CurContext);
1176 const Decl *CanonDecl =
R.Declaration->getCanonicalDecl();
1179 bool AsNestedNameSpecifier =
false;
1180 if (!isInterestingDecl(
R.Declaration, AsNestedNameSpecifier))
1187 ShadowMap &SMap = ShadowMaps.back();
1188 ShadowMapEntry::iterator I, IEnd;
1189 ShadowMap::iterator NamePos = SMap.find(
R.Declaration->getDeclName());
1190 if (NamePos != SMap.end()) {
1191 I = NamePos->second.begin();
1192 IEnd = NamePos->second.end();
1195 for (; I != IEnd; ++I) {
1197 unsigned Index = I->second;
1200 Results[Index].Declaration =
R.Declaration;
1210 std::list<ShadowMap>::iterator SM, SMEnd = ShadowMaps.end();
1212 for (SM = ShadowMaps.begin(); SM != SMEnd; ++SM) {
1213 ShadowMapEntry::iterator I, IEnd;
1214 ShadowMap::iterator NamePos = SM->find(
R.Declaration->getDeclName());
1215 if (NamePos != SM->end()) {
1216 I = NamePos->second.begin();
1217 IEnd = NamePos->second.end();
1219 for (; I != IEnd; ++I) {
1221 if (I->first->hasTagIdentifierNamespace() &&
1229 I->first->getIdentifierNamespace() != IDNS)
1233 if (CheckHiddenResult(R, CurContext, I->first))
1241 if (!AllDeclsFound.insert(CanonDecl).second)
1246 if (AsNestedNameSpecifier) {
1247 R.StartsNestedNameSpecifier =
true;
1250 AdjustResultPriorityForDecl(R);
1253 if (
R.QualifierIsInformative && !
R.Qualifier &&
1254 !
R.StartsNestedNameSpecifier) {
1255 const DeclContext *Ctx =
R.Declaration->getDeclContext();
1256 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1259 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1263 std::nullopt, Tag,
false)
1266 R.QualifierIsInformative =
false;
1271 SMap[
R.Declaration->getDeclName()].Add(
R.Declaration, Results.size());
1272 Results.push_back(R);
1274 if (!AsNestedNameSpecifier)
1275 MaybeAddConstructorResults(R);
1280 R.InBaseClass =
true;
1301 for (
unsigned I = 0, E = Candidate.
getNumParams(); I != E; ++I)
1302 if (Candidate.
parameters()[I]->getType().getCanonicalType() !=
1303 Incumbent.
parameters()[I]->getType().getCanonicalType())
1312 if (CandidateRef != IncumbentRef) {
1328 if (CandidateSuperset == IncumbentSuperset)
1340 const auto *CurrentClassScope = [&]() ->
const CXXRecordDecl * {
1342 const auto *CtxMethod = llvm::dyn_cast<CXXMethodDecl>(Ctx);
1343 if (CtxMethod && !CtxMethod->getParent()->isLambda()) {
1344 return CtxMethod->getParent();
1351 bool FunctionCanBeCall =
1352 CurrentClassScope &&
1353 (CurrentClassScope ==
Method->getParent() ||
1354 CurrentClassScope->isDerivedFrom(
Method->getParent()));
1357 if (FunctionCanBeCall)
1362 BaseExprType.
isNull() ?
nullptr
1364 auto *MaybeBase =
Method->getParent();
1366 MaybeDerived == MaybeBase || MaybeDerived->isDerivedFrom(MaybeBase);
1369 return FunctionCanBeCall;
1372bool ResultBuilder::canFunctionBeCalled(
const NamedDecl *ND,
1383 if (
const auto *FuncTmpl = dyn_cast<FunctionTemplateDecl>(ND)) {
1384 ND = FuncTmpl->getTemplatedDecl();
1386 const auto *
Method = dyn_cast<CXXMethodDecl>(ND);
1388 return canCxxMethodBeCalled(
Method, BaseExprType);
1395 NamedDecl *Hiding,
bool InBaseClass =
false,
1397 bool IsInDeclarationContext =
false,
1398 bool IsAddressOfOperand =
false) {
1399 if (
R.Kind != Result::RK_Declaration) {
1401 Results.push_back(R);
1406 if (
const auto *Using = dyn_cast<UsingShadowDecl>(
R.Declaration)) {
1408 getBasePriority(
Using->getTargetDecl()),
1412 std::move(
R.FixIts));
1414 AddResult(
Result, CurContext, Hiding,
false,
1419 bool AsNestedNameSpecifier =
false;
1420 if (!isInterestingDecl(
R.Declaration, AsNestedNameSpecifier))
1427 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
1431 if (!AllDeclsFound.insert(
R.Declaration->getCanonicalDecl()).second)
1436 if (AsNestedNameSpecifier) {
1437 R.StartsNestedNameSpecifier =
true;
1439 }
else if (Filter == &ResultBuilder::IsMember && !
R.Qualifier &&
1442 R.Declaration->getDeclContext()->getRedeclContext()))
1443 R.QualifierIsInformative =
true;
1446 if (
R.QualifierIsInformative && !
R.Qualifier &&
1447 !
R.StartsNestedNameSpecifier) {
1448 const DeclContext *Ctx =
R.Declaration->getDeclContext();
1449 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1452 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1456 std::nullopt, Tag,
false)
1459 R.QualifierIsInformative =
false;
1466 AdjustResultPriorityForDecl(R);
1469 const auto GetQualifiers = [&](
const CXXMethodDecl *MethodDecl) {
1470 if (MethodDecl->isExplicitObjectMemberFunction())
1471 return MethodDecl->getFunctionObjectParameterType().getQualifiers();
1473 return MethodDecl->getMethodQualifiers();
1476 if (IsExplicitObjectMemberFunction &&
1485 if (HasObjectTypeQualifiers)
1486 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(
R.Declaration))
1487 if (
Method->isInstance()) {
1489 if (ObjectTypeQualifiers == MethodQuals)
1491 else if (ObjectTypeQualifiers - MethodQuals) {
1497 switch (
Method->getRefQualifier()) {
1514 CurContext,
Method->getDeclName().getAsOpaqueInteger())];
1516 Result &Incumbent = Results[Entry.second];
1519 ObjectTypeQualifiers, ObjectKind,
1525 Incumbent = std::move(R);
1536 R.DeclaringEntity = IsInDeclarationContext;
1537 R.FunctionCanBeCall =
1538 canFunctionBeCalled(
R.getDeclaration(), BaseExprType) &&
1542 !IsAddressOfOperand;
1545 Results.push_back(R);
1547 if (!AsNestedNameSpecifier)
1548 MaybeAddConstructorResults(R);
1551void ResultBuilder::AddResult(
Result R) {
1552 assert(
R.Kind != Result::RK_Declaration &&
1553 "Declaration results need more context");
1554 Results.push_back(R);
1558void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1561void ResultBuilder::ExitScope() {
1562 ShadowMaps.pop_back();
1567bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1585bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1592 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1593 if (!
ID->getDefinition())
1608bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1609 if (!IsOrdinaryNonTypeName(ND))
1613 if (VD->getType()->isIntegralOrEnumerationType())
1621bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1634bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1636 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1637 ND = ClassTemplate->getTemplatedDecl();
1643bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1648bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1650 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1651 ND = ClassTemplate->getTemplatedDecl();
1654 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1663bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1665 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1666 ND = ClassTemplate->getTemplatedDecl();
1668 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1675bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1681bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1686bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1694bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1702bool ResultBuilder::IsOffsetofField(
const NamedDecl *ND)
const {
1704 if (
const auto *FD = dyn_cast<FieldDecl>(ND))
1705 return !FD->isBitField();
1706 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(ND))
1707 return !IFD->getAnonField()->isBitField();
1712 T =
C.getCanonicalType(
T);
1713 switch (
T->getTypeClass()) {
1714 case Type::ObjCObject:
1715 case Type::ObjCInterface:
1716 case Type::ObjCObjectPointer:
1721 case BuiltinType::ObjCId:
1722 case BuiltinType::ObjCClass:
1723 case BuiltinType::ObjCSel:
1735 if (!
C.getLangOpts().CPlusPlus)
1741 return T->isDependentType() ||
T->isRecordType();
1744bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1754bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1756 if (IsObjCMessageReceiver(ND))
1759 const auto *Var = dyn_cast<VarDecl>(ND);
1763 return Var->hasLocalStorage() && !Var->hasAttr<BlocksAttr>();
1766bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1767 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1768 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1777 return T->isObjCObjectType() ||
T->isObjCObjectPointerType() ||
1778 T->isObjCIdType() ||
1782bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1788bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1797 ResultBuilder &Results;
1798 DeclContext *InitialLookupCtx;
1801 CXXRecordDecl *NamingClass;
1803 std::vector<FixItHint> FixIts;
1804 bool IsInDeclarationContext;
1806 bool IsAddressOfOperand;
1809 CodeCompletionDeclConsumer(
1810 ResultBuilder &Results, DeclContext *InitialLookupCtx,
1811 QualType BaseType = QualType(),
1812 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1813 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1814 FixIts(std::move(FixIts)), IsInDeclarationContext(
false),
1815 IsAddressOfOperand(
false) {
1816 NamingClass = llvm::dyn_cast<CXXRecordDecl>(InitialLookupCtx);
1819 auto ThisType = Results.getSema().getCurrentThisType();
1820 if (!ThisType.isNull()) {
1821 assert(ThisType->isPointerType());
1827 this->BaseType = BaseType;
1830 void setIsInDeclarationContext(
bool IsInDeclarationContext) {
1831 this->IsInDeclarationContext = IsInDeclarationContext;
1834 void setIsAddressOfOperand(
bool IsAddressOfOperand) {
1835 this->IsAddressOfOperand = IsAddressOfOperand;
1838 void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx,
1839 bool InBaseClass)
override {
1840 ResultBuilder::Result
Result(ND, Results.getBasePriority(ND),
1844 Results.AddResult(
Result, InitialLookupCtx, Hiding, InBaseClass, BaseType,
1845 IsInDeclarationContext, IsAddressOfOperand);
1848 void EnteredContext(DeclContext *Ctx)
override {
1849 Results.addVisitedContext(Ctx);
1858 auto *NamingClass = this->NamingClass;
1859 QualType BaseType = this->BaseType;
1860 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1869 BaseType = QualType();
1875 NamingClass =
nullptr;
1876 BaseType = QualType();
1878 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1885 ResultBuilder &Results) {
1912 Results.getCodeCompletionTUInfo());
1913 if (LangOpts.CPlusPlus) {
1921 Builder.AddTypedTextChunk(
"typename");
1923 Builder.AddPlaceholderChunk(
"name");
1924 Results.AddResult(
Result(Builder.TakeString()));
1926 if (LangOpts.CPlusPlus11) {
1931 Builder.AddTypedTextChunk(
"decltype");
1933 Builder.AddPlaceholderChunk(
"expression");
1935 Results.AddResult(
Result(Builder.TakeString()));
1938 if (LangOpts.Char8 || LangOpts.CPlusPlus20)
1944 if (LangOpts.GNUKeywords) {
1950 Builder.AddTypedTextChunk(
"typeof");
1952 Builder.AddPlaceholderChunk(
"expression");
1953 Results.AddResult(
Result(Builder.TakeString()));
1955 Builder.AddTypedTextChunk(
"typeof");
1957 Builder.AddPlaceholderChunk(
"type");
1959 Results.AddResult(
Result(Builder.TakeString()));
1970 const LangOptions &LangOpts, ResultBuilder &Results) {
1975 Results.AddResult(
Result(
"extern"));
1976 Results.AddResult(
Result(
"static"));
1978 if (LangOpts.CPlusPlus11) {
1983 Builder.AddTypedTextChunk(
"alignas");
1985 Builder.AddPlaceholderChunk(
"expression");
1987 Results.AddResult(
Result(Builder.TakeString()));
1989 Results.AddResult(
Result(
"constexpr"));
1990 Results.AddResult(
Result(
"thread_local"));
1993 if (LangOpts.CPlusPlus20)
1994 Results.AddResult(
Result(
"constinit"));
1999 const LangOptions &LangOpts, ResultBuilder &Results) {
2004 if (LangOpts.CPlusPlus) {
2005 Results.AddResult(
Result(
"explicit"));
2006 Results.AddResult(
Result(
"friend"));
2007 Results.AddResult(
Result(
"mutable"));
2008 Results.AddResult(
Result(
"virtual"));
2016 if (LangOpts.CPlusPlus || LangOpts.C99)
2017 Results.AddResult(
Result(
"inline"));
2019 if (LangOpts.CPlusPlus20)
2020 Results.AddResult(
Result(
"consteval"));
2040 ResultBuilder &Results,
bool NeedAt);
2042 ResultBuilder &Results,
bool NeedAt);
2044 ResultBuilder &Results,
bool NeedAt);
2049 Results.getCodeCompletionTUInfo());
2050 Builder.AddTypedTextChunk(
"typedef");
2052 Builder.AddPlaceholderChunk(
"type");
2054 Builder.AddPlaceholderChunk(
"name");
2061 ResultBuilder &Results) {
2062 Builder.AddTypedTextChunk(
"using");
2064 Builder.AddPlaceholderChunk(
"name");
2066 Builder.AddPlaceholderChunk(
"type");
2089 return LangOpts.CPlusPlus;
2096 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
2099 llvm_unreachable(
"Invalid ParserCompletionContext!");
2126 if (!
T.getLocalQualifiers()) {
2129 return BT->getNameAsCString(Policy);
2132 if (
const TagType *TagT = dyn_cast<TagType>(
T))
2133 if (
TagDecl *Tag = TagT->getDecl())
2134 if (!Tag->hasNameForLinkage()) {
2135 switch (Tag->getTagKind()) {
2137 return "struct <anonymous>";
2139 return "__interface <anonymous>";
2141 return "class <anonymous>";
2143 return "union <anonymous>";
2145 return "enum <anonymous>";
2152 T.getAsStringInternal(
Result, Policy);
2165 Builder.AddResultTypeChunk(
2167 Builder.AddTypedTextChunk(
"this");
2172 ResultBuilder &Results,
2174 if (!LangOpts.CPlusPlus11)
2177 Builder.AddTypedTextChunk(
"static_assert");
2179 Builder.AddPlaceholderChunk(
"expression");
2181 Builder.AddPlaceholderChunk(
"message");
2190 Sema &S = Results.getSema();
2191 const auto *CR = llvm::dyn_cast<CXXRecordDecl>(S.
CurContext);
2197 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
2198 for (
auto *Method : CR->methods()) {
2199 if (!Method->isVirtual() || !Method->getIdentifier())
2201 Overrides[Method->getName()].push_back(Method);
2204 for (
const auto &
Base : CR->bases()) {
2205 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
2208 for (
auto *Method : BR->methods()) {
2209 if (!Method->isVirtual() || !Method->getIdentifier())
2211 const auto it = Overrides.find(Method->getName());
2212 bool IsOverriden =
false;
2213 if (it != Overrides.end()) {
2214 for (
auto *MD : it->second) {
2232 false, CCContext, Policy);
2242 Scope *S,
Sema &SemaRef, ResultBuilder &Results) {
2250 if (Results.includeCodePatterns()) {
2252 Builder.AddTypedTextChunk(
"namespace");
2254 Builder.AddPlaceholderChunk(
"identifier");
2258 Builder.AddPlaceholderChunk(
"declarations");
2261 Results.AddResult(
Result(Builder.TakeString()));
2265 Builder.AddTypedTextChunk(
"namespace");
2267 Builder.AddPlaceholderChunk(
"name");
2269 Builder.AddPlaceholderChunk(
"namespace");
2271 Results.AddResult(
Result(Builder.TakeString()));
2274 Builder.AddTypedTextChunk(
"using namespace");
2276 Builder.AddPlaceholderChunk(
"identifier");
2278 Results.AddResult(
Result(Builder.TakeString()));
2281 Builder.AddTypedTextChunk(
"asm");
2283 Builder.AddPlaceholderChunk(
"string-literal");
2285 Results.AddResult(
Result(Builder.TakeString()));
2287 if (Results.includeCodePatterns()) {
2289 Builder.AddTypedTextChunk(
"template");
2291 Builder.AddPlaceholderChunk(
"declaration");
2292 Results.AddResult(
Result(Builder.TakeString()));
2303 if (!CurrentModule) {
2305 Builder.AddTypedTextChunk(
"module");
2308 Results.AddResult(
Result(Builder.TakeString()));
2313 if (!CurrentModule ||
2318 Builder.AddTypedTextChunk(
"module");
2320 Builder.AddPlaceholderChunk(
"name");
2323 Results.AddResult(
Result(Builder.TakeString()));
2328 if (!CurrentModule ||
2332 Builder.AddTypedTextChunk(
"import");
2334 Builder.AddPlaceholderChunk(
"name");
2337 Results.AddResult(
Result(Builder.TakeString()));
2340 if (CurrentModule &&
2344 Builder.AddTypedTextChunk(
"module");
2347 Builder.AddTypedTextChunk(
"private");
2350 Results.AddResult(
Result(Builder.TakeString()));
2355 if (!CurrentModule ||
2370 Builder.AddTypedTextChunk(
"using");
2372 Builder.AddPlaceholderChunk(
"qualifier");
2373 Builder.AddTextChunk(
"::");
2374 Builder.AddPlaceholderChunk(
"name");
2376 Results.AddResult(
Result(Builder.TakeString()));
2383 Builder.AddTypedTextChunk(
"using typename");
2385 Builder.AddPlaceholderChunk(
"qualifier");
2386 Builder.AddTextChunk(
"::");
2387 Builder.AddPlaceholderChunk(
"name");
2389 Results.AddResult(
Result(Builder.TakeString()));
2399 Builder.AddTypedTextChunk(
"public");
2400 if (IsNotInheritanceScope && Results.includeCodePatterns())
2402 Results.AddResult(
Result(Builder.TakeString()));
2405 Builder.AddTypedTextChunk(
"protected");
2406 if (IsNotInheritanceScope && Results.includeCodePatterns())
2408 Results.AddResult(
Result(Builder.TakeString()));
2411 Builder.AddTypedTextChunk(
"private");
2412 if (IsNotInheritanceScope && Results.includeCodePatterns())
2414 Results.AddResult(
Result(Builder.TakeString()));
2432 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
2434 Builder.AddTypedTextChunk(
"template");
2436 Builder.AddPlaceholderChunk(
"parameters");
2438 Results.AddResult(
Result(Builder.TakeString()));
2476 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
2478 Builder.AddTypedTextChunk(
"try");
2482 Builder.AddPlaceholderChunk(
"statements");
2486 Builder.AddTextChunk(
"catch");
2489 Builder.AddPlaceholderChunk(
"declaration");
2494 Builder.AddPlaceholderChunk(
"statements");
2497 Results.AddResult(
Result(Builder.TakeString()));
2502 if (Results.includeCodePatterns()) {
2504 Builder.AddTypedTextChunk(
"if");
2508 Builder.AddPlaceholderChunk(
"condition");
2510 Builder.AddPlaceholderChunk(
"expression");
2515 Builder.AddPlaceholderChunk(
"statements");
2518 Results.AddResult(
Result(Builder.TakeString()));
2521 Builder.AddTypedTextChunk(
"switch");
2525 Builder.AddPlaceholderChunk(
"condition");
2527 Builder.AddPlaceholderChunk(
"expression");
2532 Builder.AddPlaceholderChunk(
"cases");
2535 Results.AddResult(
Result(Builder.TakeString()));
2542 Builder.AddTypedTextChunk(
"case");
2544 Builder.AddPlaceholderChunk(
"expression");
2546 Results.AddResult(
Result(Builder.TakeString()));
2549 Builder.AddTypedTextChunk(
"default");
2551 Results.AddResult(
Result(Builder.TakeString()));
2554 if (Results.includeCodePatterns()) {
2556 Builder.AddTypedTextChunk(
"while");
2560 Builder.AddPlaceholderChunk(
"condition");
2562 Builder.AddPlaceholderChunk(
"expression");
2567 Builder.AddPlaceholderChunk(
"statements");
2570 Results.AddResult(
Result(Builder.TakeString()));
2573 Builder.AddTypedTextChunk(
"do");
2577 Builder.AddPlaceholderChunk(
"statements");
2580 Builder.AddTextChunk(
"while");
2583 Builder.AddPlaceholderChunk(
"expression");
2585 Results.AddResult(
Result(Builder.TakeString()));
2588 Builder.AddTypedTextChunk(
"for");
2592 Builder.AddPlaceholderChunk(
"init-statement");
2594 Builder.AddPlaceholderChunk(
"init-expression");
2597 Builder.AddPlaceholderChunk(
"condition");
2600 Builder.AddPlaceholderChunk(
"inc-expression");
2605 Builder.AddPlaceholderChunk(
"statements");
2608 Results.AddResult(
Result(Builder.TakeString()));
2612 Builder.AddTypedTextChunk(
"for");
2615 Builder.AddPlaceholderChunk(
"range-declaration");
2618 Builder.AddTextChunk(
"in");
2622 Builder.AddPlaceholderChunk(
"range-expression");
2627 Builder.AddPlaceholderChunk(
"statements");
2630 Results.AddResult(
Result(Builder.TakeString()));
2636 Builder.AddTypedTextChunk(
"continue");
2638 Results.AddResult(
Result(Builder.TakeString()));
2643 Builder.AddTypedTextChunk(
"break");
2645 Results.AddResult(
Result(Builder.TakeString()));
2650 if (
const auto *Function = dyn_cast<FunctionDecl>(SemaRef.
CurContext)) {
2651 if (!Function->getType().isNull())
2652 ReturnType = Function->getReturnType();
2653 }
else if (
const auto *Method =
2654 dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
2655 ReturnType = Method->getReturnType();
2660 Builder.AddTypedTextChunk(
"return");
2662 Results.AddResult(
Result(Builder.TakeString()));
2664 assert(!ReturnType.
isNull());
2666 Builder.AddTypedTextChunk(
"return");
2668 Builder.AddPlaceholderChunk(
"expression");
2670 Results.AddResult(
Result(Builder.TakeString()));
2673 Builder.AddTypedTextChunk(
"co_return");
2675 Builder.AddPlaceholderChunk(
"expression");
2677 Results.AddResult(
Result(Builder.TakeString()));
2681 Builder.AddTypedTextChunk(
"return true");
2683 Results.AddResult(
Result(Builder.TakeString()));
2685 Builder.AddTypedTextChunk(
"return false");
2687 Results.AddResult(
Result(Builder.TakeString()));
2692 Builder.AddTypedTextChunk(
"return nullptr");
2694 Results.AddResult(
Result(Builder.TakeString()));
2699 Builder.AddTypedTextChunk(
"goto");
2701 Builder.AddPlaceholderChunk(
"label");
2703 Results.AddResult(
Result(Builder.TakeString()));
2706 Builder.AddTypedTextChunk(
"using namespace");
2708 Builder.AddPlaceholderChunk(
"identifier");
2710 Results.AddResult(
Result(Builder.TakeString()));
2727 Builder.AddTypedTextChunk(
"__bridge");
2729 Builder.AddPlaceholderChunk(
"type");
2731 Builder.AddPlaceholderChunk(
"expression");
2732 Results.AddResult(
Result(Builder.TakeString()));
2735 Builder.AddTypedTextChunk(
"__bridge_transfer");
2737 Builder.AddPlaceholderChunk(
"Objective-C type");
2739 Builder.AddPlaceholderChunk(
"expression");
2740 Results.AddResult(
Result(Builder.TakeString()));
2743 Builder.AddTypedTextChunk(
"__bridge_retained");
2745 Builder.AddPlaceholderChunk(
"CF type");
2747 Builder.AddPlaceholderChunk(
"expression");
2748 Results.AddResult(
Result(Builder.TakeString()));
2759 Builder.AddResultTypeChunk(
"bool");
2760 Builder.AddTypedTextChunk(
"true");
2761 Results.AddResult(
Result(Builder.TakeString()));
2764 Builder.AddResultTypeChunk(
"bool");
2765 Builder.AddTypedTextChunk(
"false");
2766 Results.AddResult(
Result(Builder.TakeString()));
2770 Builder.AddTypedTextChunk(
"dynamic_cast");
2772 Builder.AddPlaceholderChunk(
"type");
2775 Builder.AddPlaceholderChunk(
"expression");
2777 Results.AddResult(
Result(Builder.TakeString()));
2781 Builder.AddTypedTextChunk(
"static_cast");
2783 Builder.AddPlaceholderChunk(
"type");
2786 Builder.AddPlaceholderChunk(
"expression");
2788 Results.AddResult(
Result(Builder.TakeString()));
2791 Builder.AddTypedTextChunk(
"reinterpret_cast");
2793 Builder.AddPlaceholderChunk(
"type");
2796 Builder.AddPlaceholderChunk(
"expression");
2798 Results.AddResult(
Result(Builder.TakeString()));
2801 Builder.AddTypedTextChunk(
"const_cast");
2803 Builder.AddPlaceholderChunk(
"type");
2806 Builder.AddPlaceholderChunk(
"expression");
2808 Results.AddResult(
Result(Builder.TakeString()));
2812 Builder.AddResultTypeChunk(
"std::type_info");
2813 Builder.AddTypedTextChunk(
"typeid");
2815 Builder.AddPlaceholderChunk(
"expression-or-type");
2817 Results.AddResult(
Result(Builder.TakeString()));
2821 Builder.AddTypedTextChunk(
"new");
2823 Builder.AddPlaceholderChunk(
"type");
2825 Builder.AddPlaceholderChunk(
"expressions");
2827 Results.AddResult(
Result(Builder.TakeString()));
2830 Builder.AddTypedTextChunk(
"new");
2832 Builder.AddPlaceholderChunk(
"type");
2834 Builder.AddPlaceholderChunk(
"size");
2837 Builder.AddPlaceholderChunk(
"expressions");
2839 Results.AddResult(
Result(Builder.TakeString()));
2842 Builder.AddResultTypeChunk(
"void");
2843 Builder.AddTypedTextChunk(
"delete");
2845 Builder.AddPlaceholderChunk(
"expression");
2846 Results.AddResult(
Result(Builder.TakeString()));
2849 Builder.AddResultTypeChunk(
"void");
2850 Builder.AddTypedTextChunk(
"delete");
2855 Builder.AddPlaceholderChunk(
"expression");
2856 Results.AddResult(
Result(Builder.TakeString()));
2860 Builder.AddResultTypeChunk(
"void");
2861 Builder.AddTypedTextChunk(
"throw");
2863 Builder.AddPlaceholderChunk(
"expression");
2864 Results.AddResult(
Result(Builder.TakeString()));
2871 Builder.AddResultTypeChunk(
"std::nullptr_t");
2872 Builder.AddTypedTextChunk(
"nullptr");
2873 Results.AddResult(
Result(Builder.TakeString()));
2876 Builder.AddResultTypeChunk(
"size_t");
2877 Builder.AddTypedTextChunk(
"alignof");
2879 Builder.AddPlaceholderChunk(
"type");
2881 Results.AddResult(
Result(Builder.TakeString()));
2884 Builder.AddResultTypeChunk(
"bool");
2885 Builder.AddTypedTextChunk(
"noexcept");
2887 Builder.AddPlaceholderChunk(
"expression");
2889 Results.AddResult(
Result(Builder.TakeString()));
2892 Builder.AddResultTypeChunk(
"size_t");
2893 Builder.AddTypedTextChunk(
"sizeof...");
2895 Builder.AddPlaceholderChunk(
"parameter-pack");
2897 Results.AddResult(
Result(Builder.TakeString()));
2902 Builder.AddTypedTextChunk(
"co_await");
2904 Builder.AddPlaceholderChunk(
"expression");
2905 Results.AddResult(
Result(Builder.TakeString()));
2908 Builder.AddTypedTextChunk(
"co_yield");
2910 Builder.AddPlaceholderChunk(
"expression");
2911 Results.AddResult(
Result(Builder.TakeString()));
2914 Builder.AddResultTypeChunk(
"bool");
2915 Builder.AddTypedTextChunk(
"requires");
2918 Builder.AddPlaceholderChunk(
"parameters");
2923 Builder.AddPlaceholderChunk(
"requirements");
2926 Results.AddResult(
Result(Builder.TakeString()));
2930 Builder.AddTypedTextChunk(
"requires");
2932 Builder.AddPlaceholderChunk(
"expression");
2934 Results.AddResult(
Result(Builder.TakeString()));
2944 if (ID->getSuperClass()) {
2945 std::string SuperType;
2946 SuperType = ID->getSuperClass()->getNameAsString();
2947 if (Method->isInstanceMethod())
2950 Builder.AddResultTypeChunk(Allocator.
CopyString(SuperType));
2951 Builder.AddTypedTextChunk(
"super");
2952 Results.AddResult(
Result(Builder.TakeString()));
2961 Builder.AddResultTypeChunk(
"size_t");
2963 Builder.AddTypedTextChunk(
"alignof");
2965 Builder.AddTypedTextChunk(
"_Alignof");
2967 Builder.AddPlaceholderChunk(
"type");
2969 Results.AddResult(
Result(Builder.TakeString()));
2974 Builder.AddResultTypeChunk(
"nullptr_t");
2975 Builder.AddTypedTextChunk(
"nullptr");
2976 Results.AddResult(
Result(Builder.TakeString()));
2980 Builder.AddResultTypeChunk(
"size_t");
2981 Builder.AddTypedTextChunk(
"sizeof");
2983 Builder.AddPlaceholderChunk(
"expression-or-type");
2985 Results.AddResult(
Result(Builder.TakeString()));
2998 Results.AddResult(
Result(
"operator"));
3018 T = Function->getReturnType();
3019 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3020 if (!BaseType.isNull())
3021 T = Method->getSendResultType(BaseType);
3023 T = Method->getReturnType();
3024 }
else if (
const auto *
Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
3025 T = Context.getCanonicalTagType(
3029 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
3030 if (!BaseType.isNull())
3031 T = Ivar->getUsageType(BaseType);
3033 T = Ivar->getType();
3034 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
3036 }
else if (
const auto *Property = dyn_cast<ObjCPropertyDecl>(ND)) {
3037 if (!BaseType.isNull())
3038 T = Property->getUsageType(BaseType);
3040 T = Property->getType();
3043 if (
T.isNull() || Context.hasSameType(
T, Context.DependentTy))
3046 Result.AddResultTypeChunk(
3053 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
3054 if (Sentinel->getSentinel() == 0) {
3056 Result.AddTextChunk(
", nil");
3058 Result.AddTextChunk(
", NULL");
3060 Result.AddTextChunk(
", (void*)0");
3080 if (
auto nullability = AttributedType::stripOuterNullability(
Type)) {
3081 switch (*nullability) {
3091 Result +=
"null_unspecified ";
3095 llvm_unreachable(
"Not supported as a context-sensitive keyword!");
3112 bool SuppressBlock =
false) {
3118 if (!SuppressBlock) {
3121 TypedefTL.getDecl()->getTypeSourceInfo()) {
3134 TL = AttrTL.getModifiedLoc();
3153 bool SuppressBlockName =
false,
bool SuppressBlock =
false,
3158 bool SuppressName =
false,
bool SuppressBlock =
false,
3166 if (
const auto *PVD = dyn_cast<ParmVarDecl>(Param))
3167 ObjCQual = PVD->getObjCDeclQualifier();
3169 if (Param->getType()->isDependentType() ||
3170 !Param->getType()->isBlockPointerType()) {
3175 if (Param->getIdentifier() && !ObjCMethodParam && !SuppressName)
3176 Result = std::string(Param->getIdentifier()->deuglifiedName());
3180 Type =
Type.substObjCTypeArgs(Param->getASTContext(), *ObjCSubsts,
3182 if (ObjCMethodParam) {
3185 if (Param->getIdentifier() && !SuppressName)
3186 Result += Param->getIdentifier()->deuglifiedName();
3201 if (!
Block && ObjCMethodParam &&
3204 ->findPropertyDecl(
false))
3213 if (!ObjCMethodParam && Param->getIdentifier())
3214 Result = std::string(Param->getIdentifier()->deuglifiedName());
3218 if (ObjCMethodParam) {
3223 if (
Result.back() !=
')')
3225 if (Param->getIdentifier())
3226 Result += Param->getIdentifier()->deuglifiedName();
3237 false, SuppressBlock,
3253 bool SuppressBlockName,
bool SuppressBlock,
3261 if (!ResultType->
isVoidType() || SuppressBlock)
3266 if (!BlockProto ||
Block.getNumParams() == 0) {
3273 for (
unsigned I = 0, N =
Block.getNumParams(); I != N; ++I) {
3286 if (SuppressBlock) {
3289 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3298 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3308 const SourceRange SrcRange = Param->getDefaultArgRange();
3318 if (srcText.empty() || srcText ==
"=") {
3324 std::string DefValue(srcText.str());
3327 if (DefValue.at(0) !=
'=') {
3331 return " = " + DefValue;
3333 return " " + DefValue;
3340 unsigned Start = 0,
bool InOptional =
false,
bool FunctionCanBeCall =
true,
3341 bool IsInDeclarationContext =
false) {
3342 bool FirstParameter =
true;
3343 bool AsInformativeChunk = !(FunctionCanBeCall || IsInDeclarationContext);
3345 const FunctionDecl *BetterSignatureDecl = BetterSignature(Function, Start);
3347 for (
unsigned P = Start, N = Function->getNumParams(); P != N; ++P) {
3350 if (Param->hasDefaultArg() && !InOptional && !IsInDeclarationContext &&
3351 !AsInformativeChunk) {
3355 Result.getCodeCompletionTUInfo());
3356 if (!FirstParameter)
3366 if (FirstParameter && Param->isExplicitObjectParameter()) {
3371 FirstParameter =
false;
3373 if (AsInformativeChunk)
3374 Result.AddInformativeChunk(
", ");
3383 std::string DefaultValue;
3384 if (Param->hasDefaultArg()) {
3385 if (IsInDeclarationContext)
3393 if (Function->isVariadic() && P == N - 1)
3394 PlaceholderStr +=
", ...";
3397 if (AsInformativeChunk)
3398 Result.AddInformativeChunk(
3399 Result.getAllocator().CopyString(PlaceholderStr));
3400 else if (IsInDeclarationContext) {
3401 Result.AddTextChunk(
Result.getAllocator().CopyString(PlaceholderStr));
3402 if (DefaultValue.length() != 0)
3403 Result.AddInformativeChunk(
3404 Result.getAllocator().CopyString(DefaultValue));
3406 Result.AddPlaceholderChunk(
3407 Result.getAllocator().CopyString(PlaceholderStr));
3411 if (Proto->isVariadic()) {
3412 if (Proto->getNumParams() == 0)
3413 Result.AddPlaceholderChunk(
"...");
3423 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false,
3424 bool AsInformativeChunk =
false) {
3425 bool FirstParameter =
true;
3434 PEnd = Params->
begin() + MaxParameters;
3437 bool HasDefaultArg =
false;
3438 std::string PlaceholderStr;
3440 if (TTP->wasDeclaredWithTypename())
3441 PlaceholderStr =
"typename";
3442 else if (
const auto *TC = TTP->getTypeConstraint()) {
3443 llvm::raw_string_ostream OS(PlaceholderStr);
3444 TC->print(OS, Policy);
3446 PlaceholderStr =
"class";
3448 if (TTP->getIdentifier()) {
3449 PlaceholderStr +=
' ';
3450 PlaceholderStr += TTP->getIdentifier()->deuglifiedName();
3453 HasDefaultArg = TTP->hasDefaultArgument();
3455 dyn_cast<NonTypeTemplateParmDecl>(*P)) {
3456 if (NTTP->getIdentifier())
3457 PlaceholderStr = std::string(NTTP->getIdentifier()->deuglifiedName());
3458 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
3459 HasDefaultArg = NTTP->hasDefaultArgument();
3466 PlaceholderStr =
"template<...> class";
3468 PlaceholderStr +=
' ';
3475 if (HasDefaultArg && !InDefaultArg && !AsInformativeChunk) {
3479 Result.getCodeCompletionTUInfo());
3480 if (!FirstParameter)
3483 P - Params->
begin(),
true);
3488 InDefaultArg =
false;
3491 FirstParameter =
false;
3493 if (AsInformativeChunk)
3494 Result.AddInformativeChunk(
", ");
3499 if (AsInformativeChunk)
3500 Result.AddInformativeChunk(
3501 Result.getAllocator().CopyString(PlaceholderStr));
3503 Result.AddPlaceholderChunk(
3504 Result.getAllocator().CopyString(PlaceholderStr));
3512 bool QualifierIsInformative,
3518 std::string PrintedNNS;
3520 llvm::raw_string_ostream OS(PrintedNNS);
3521 Qualifier.print(OS, Policy);
3523 if (QualifierIsInformative)
3524 Result.AddInformativeChunk(
Result.getAllocator().CopyString(PrintedNNS));
3526 Result.AddTextChunk(
Result.getAllocator().CopyString(PrintedNNS));
3531 bool AsInformativeChunk =
true) {
3536 if (AsInformativeChunk)
3537 Result.AddInformativeChunk(
" const");
3539 Result.AddTextChunk(
" const");
3544 if (AsInformativeChunk)
3545 Result.AddInformativeChunk(
" volatile");
3547 Result.AddTextChunk(
" volatile");
3552 if (AsInformativeChunk)
3553 Result.AddInformativeChunk(
" restrict");
3555 Result.AddTextChunk(
" restrict");
3560 std::string QualsStr;
3562 QualsStr +=
" const";
3564 QualsStr +=
" volatile";
3566 QualsStr +=
" restrict";
3568 if (AsInformativeChunk)
3569 Result.AddInformativeChunk(
Result.getAllocator().CopyString(QualsStr));
3571 Result.AddTextChunk(
Result.getAllocator().CopyString(QualsStr));
3577 bool AsInformativeChunks =
true) {
3578 if (
auto *CxxMethodDecl = llvm::dyn_cast_if_present<CXXMethodDecl>(Function);
3579 CxxMethodDecl && CxxMethodDecl->hasCXXExplicitFunctionObjectParameter()) {
3581 const auto Quals = CxxMethodDecl->getFunctionObjectParameterType();
3582 if (!Quals.hasQualifiers())
3588 if (!Proto || !Proto->getMethodQuals())
3603 switch (ExceptInfo.Type) {
3606 NameAndSignature +=
" noexcept";
3624 const char *OperatorName =
nullptr;
3627 case OO_Conditional:
3629 OperatorName =
"operator";
3632#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
3634 OperatorName = "operator" Spelling; \
3636#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly)
3637#include "clang/Basic/OperatorKinds.def"
3640 OperatorName =
"operator new";
3643 OperatorName =
"operator delete";
3646 OperatorName =
"operator new[]";
3648 case OO_Array_Delete:
3649 OperatorName =
"operator delete[]";
3652 OperatorName =
"operator()";
3655 OperatorName =
"operator[]";
3658 Result.AddTypedTextChunk(OperatorName);
3666 Result.AddTypedTextChunk(
3683 Result.AddTypedTextChunk(
3688 Result.AddTypedTextChunk(
3689 Result.getAllocator().CopyString(
Record->getNameAsString()));
3703 bool IncludeBriefComments) {
3705 CCTUInfo, IncludeBriefComments);
3717 return Result.TakeString();
3728 Result.AddPlaceholderChunk(
"...");
3742 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3747 Result.AddPlaceholderChunk(
3748 Result.getAllocator().CopyString((*A)->getName()));
3751 return Result.TakeString();
3763 bool IncludeBriefComments) {
3779 Result.addBriefComment(RC->getBriefText(Ctx));
3789 return Result.TakeString();
3793 PP, Ctx,
Result, IncludeBriefComments, CCContext, Policy);
3797 std::string &BeforeName,
3798 std::string &NameAndSignature) {
3799 bool SeenTypedChunk =
false;
3800 for (
auto &Chunk : CCS) {
3802 assert(SeenTypedChunk &&
"optional parameter before name");
3809 NameAndSignature += Chunk.Text;
3811 BeforeName += Chunk.Text;
3823 std::string BeforeName;
3824 std::string NameAndSignature;
3830 const auto *VirtualFunc = dyn_cast<FunctionDecl>(
Declaration);
3831 assert(VirtualFunc &&
"overridden decl must be a function");
3834 NameAndSignature +=
" override";
3836 Result.AddTextChunk(
Result.getAllocator().CopyString(BeforeName));
3838 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(NameAndSignature));
3839 return Result.TakeString();
3845 const auto *VD = dyn_cast<VarDecl>(ND);
3848 const auto *
RecordDecl = VD->getType()->getAsCXXRecordDecl();
3861 if (IncludeBriefComments) {
3864 Result.addBriefComment(RC->getBriefText(Ctx));
3869 Result.AddTypedTextChunk(
3871 Result.AddTextChunk(
"::");
3872 return Result.TakeString();
3876 Result.AddAnnotation(
Result.getAllocator().CopyString(I->getAnnotation()));
3884 if (InsertParameters)
3887 Result.AddInformativeChunk(
"(");
3892 if (InsertParameters)
3895 Result.AddInformativeChunk(
")");
3900 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND)) {
3901 AddFunctionTypeAndResult(
Function);
3902 return Result.TakeString();
3905 if (
const auto *CallOperator =
3907 AddFunctionTypeAndResult(CallOperator);
3908 return Result.TakeString();
3914 dyn_cast<FunctionTemplateDecl>(ND)) {
3925 llvm::SmallBitVector
Deduced(FunTmpl->getTemplateParameters()->size());
3930 unsigned LastDeducibleArgument;
3931 for (LastDeducibleArgument =
Deduced.size(); LastDeducibleArgument > 0;
3932 --LastDeducibleArgument) {
3933 if (!
Deduced[LastDeducibleArgument - 1]) {
3937 bool HasDefaultArg =
false;
3938 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3939 LastDeducibleArgument - 1);
3941 HasDefaultArg = TTP->hasDefaultArgument();
3943 dyn_cast<NonTypeTemplateParmDecl>(Param))
3944 HasDefaultArg = NTTP->hasDefaultArgument();
3972 Result.AddInformativeChunk(
"<");
3974 Ctx, Policy, FunTmpl,
Result, LastDeducibleArgument, 0,
3981 Result.AddInformativeChunk(
">");
3986 if (InsertParameters)
3989 Result.AddInformativeChunk(
"(");
3994 if (InsertParameters)
3997 Result.AddInformativeChunk(
")");
3999 return Result.TakeString();
4002 if (
const auto *
Template = dyn_cast<TemplateDecl>(ND)) {
4005 Result.AddTypedTextChunk(
4010 return Result.TakeString();
4013 if (
const auto *
Method = dyn_cast<ObjCMethodDecl>(ND)) {
4016 Result.AddTypedTextChunk(
4018 return Result.TakeString();
4024 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(SelName));
4026 Result.AddInformativeChunk(
Result.getAllocator().CopyString(SelName));
4030 if (
Method->param_size() == 1)
4031 Result.AddTypedTextChunk(
"");
4037 PEnd =
Method->param_end();
4038 P != PEnd && Idx < Sel.
getNumArgs(); (
void)++P, ++Idx) {
4057 QualType ParamType = (*P)->getType();
4058 std::optional<ArrayRef<QualType>> ObjCSubsts;
4074 Arg += II->getName();
4077 if (
Method->isVariadic() && (P + 1) == PEnd)
4081 Result.AddTextChunk(
Result.getAllocator().CopyString(Arg));
4083 Result.AddInformativeChunk(
Result.getAllocator().CopyString(Arg));
4085 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
4088 if (
Method->isVariadic()) {
4089 if (
Method->param_size() == 0) {
4091 Result.AddTextChunk(
", ...");
4093 Result.AddInformativeChunk(
", ...");
4095 Result.AddPlaceholderChunk(
", ...");
4101 return Result.TakeString();
4108 Result.AddTypedTextChunk(
4110 return Result.TakeString();
4121 const auto *M = dyn_cast<ObjCMethodDecl>(ND);
4133 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
4134 if (!M || !M->isPropertyAccessor())
4157 auto FDecl =
Result.getFunction();
4160 if (ArgIndex < FDecl->getNumParams())
4168 unsigned CurrentArg) {
4169 unsigned ChunkIndex = 0;
4170 auto AddChunk = [&](llvm::StringRef Placeholder) {
4173 const char *
Copy =
Result.getAllocator().CopyString(Placeholder);
4174 if (ChunkIndex == CurrentArg)
4182 if (
auto *CRD = llvm::dyn_cast<CXXRecordDecl>(RD)) {
4183 for (
const auto &
Base : CRD->bases())
4184 AddChunk(
Base.getType().getAsString(Policy));
4186 for (
const auto &Field : RD->
fields())
4196 unsigned CurrentArg,
unsigned Start = 0,
bool InOptional =
false) {
4202 bool FirstParameter =
true;
4203 unsigned NumParams =
4204 Function ? Function->getNumParams() :
Prototype->getNumParams();
4206 Function ? BetterSignature(Function, Start) :
nullptr;
4208 for (
unsigned P = Start; P != NumParams; ++P) {
4209 if (Function && Function->getParamDecl(P)->hasDefaultArg() && !InOptional) {
4213 Result.getCodeCompletionTUInfo());
4214 if (!FirstParameter)
4218 PrototypeLoc, Opt, CurrentArg, P,
4227 if (Function && FirstParameter &&
4228 Function->getParamDecl(P)->isExplicitObjectParameter()) {
4233 FirstParameter =
false;
4240 std::string Placeholder;
4241 assert(P < Prototype->getNumParams());
4242 if (Function || PrototypeLoc) {
4246 if (Param->hasDefaultArg())
4248 Context.getLangOpts());
4250 Placeholder =
Prototype->getParamType(P).getAsString(Policy);
4253 if (P == CurrentArg)
4254 Result.AddCurrentParameterChunk(
4255 Result.getAllocator().CopyString(Placeholder));
4257 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Placeholder));
4262 Result.getCodeCompletionTUInfo());
4263 if (!FirstParameter)
4266 if (CurrentArg < NumParams)
4278 if (
const auto *
Type = dyn_cast<TemplateTypeParmDecl>(Param)) {
4280 }
else if (
const auto *
NonType = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4282 }
else if (
const auto *
Template = dyn_cast<TemplateTemplateParmDecl>(Param)) {
4286 llvm::raw_string_ostream OS(
Result);
4287 Param->print(OS, Policy);
4293 if (
const auto *CTD = dyn_cast<ClassTemplateDecl>(TD))
4294 return CTD->getTemplatedDecl()->getKindName().str();
4295 if (
const auto *VTD = dyn_cast<VarTemplateDecl>(TD))
4296 return VTD->getTemplatedDecl()->getType().getAsString(Policy);
4297 if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(TD))
4298 return FTD->getTemplatedDecl()->getReturnType().getAsString(Policy);
4313 Builder.getCodeCompletionTUInfo());
4315 if (!ResultType.empty())
4316 Builder.AddResultTypeChunk(Builder.getAllocator().CopyString(ResultType));
4317 Builder.AddTextChunk(
4323 for (
unsigned I = 0; I < Params.size(); ++I) {
4325 std::string Placeholder =
4328 Current = &OptionalBuilder;
4337 if (Current == &OptionalBuilder)
4343 Builder.AddInformativeChunk(
"()");
4344 return Builder.TakeString();
4351 bool Braced)
const {
4375 if (IncludeBriefComments) {
4382 llvm::raw_string_ostream OS(Name);
4384 Result.AddTextChunk(
Result.getAllocator().CopyString(Name));
4387 Result.AddResultTypeChunk(
Result.getAllocator().CopyString(
4402 return Result.TakeString();
4407 bool PreferredTypeIsPointer) {
4411 if (MacroName ==
"nil" || MacroName ==
"NULL" || MacroName ==
"Nil") {
4413 if (PreferredTypeIsPointer)
4417 else if (MacroName ==
"YES" || MacroName ==
"NO" || MacroName ==
"true" ||
4418 MacroName ==
"false")
4421 else if (MacroName ==
"bool")
4434 case Decl::EnumConstant:
4438 case Decl::Function:
4440 case Decl::ObjCCategory:
4442 case Decl::ObjCCategoryImpl:
4444 case Decl::ObjCImplementation:
4447 case Decl::ObjCInterface:
4449 case Decl::ObjCIvar:
4451 case Decl::ObjCMethod:
4455 case Decl::CXXMethod:
4457 case Decl::CXXConstructor:
4459 case Decl::CXXDestructor:
4461 case Decl::CXXConversion:
4463 case Decl::ObjCProperty:
4465 case Decl::ObjCProtocol:
4471 case Decl::TypeAlias:
4473 case Decl::TypeAliasTemplate:
4477 case Decl::Namespace:
4479 case Decl::NamespaceAlias:
4481 case Decl::TemplateTypeParm:
4483 case Decl::NonTypeTemplateParm:
4485 case Decl::TemplateTemplateParm:
4487 case Decl::FunctionTemplate:
4489 case Decl::ClassTemplate:
4491 case Decl::AccessSpec:
4493 case Decl::ClassTemplatePartialSpecialization:
4495 case Decl::UsingDirective:
4497 case Decl::StaticAssert:
4500 case Decl::FriendTemplate:
4502 case Decl::TranslationUnit:
4506 case Decl::UnresolvedUsingValue:
4507 case Decl::UnresolvedUsingTypename:
4510 case Decl::UsingEnum:
4513 case Decl::ObjCPropertyImpl:
4521 llvm_unreachable(
"Unexpected Kind!");
4526 case Decl::ObjCTypeParam:
4532 case Decl::LinkageSpec:
4536 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
4537 switch (TD->getTagKind()) {
4555 bool LoadExternal,
bool IncludeUndefined,
4556 bool TargetTypeIsPointer =
false) {
4559 Results.EnterNewScope();
4561 for (
const auto &M : PP.
macros(LoadExternal)) {
4563 if (IncludeUndefined || MD) {
4571 TargetTypeIsPointer)));
4575 Results.ExitScope();
4579 ResultBuilder &Results) {
4582 Results.EnterNewScope();
4586 if (LangOpts.C99 || LangOpts.CPlusPlus11)
4588 Results.ExitScope();
4595 unsigned NumResults) {
4600static CodeCompletionContext
4658 llvm_unreachable(
"Invalid ParserCompletionContext!");
4670 ResultBuilder &Results) {
4676 CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(CurContext);
4677 if (!Method || !Method->isVirtual())
4682 for (
auto *P : Method->parameters())
4683 if (!P->getDeclName())
4689 Results.getCodeCompletionTUInfo());
4690 if (Overridden->getCanonicalDecl() == Method->getCanonicalDecl())
4696 S.
Context, CurContext, Overridden->getDeclContext());
4699 llvm::raw_string_ostream OS(Str);
4700 NNS.
print(OS, Policy);
4701 Builder.AddTextChunk(Results.getAllocator().CopyString(Str));
4703 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
4706 Builder.AddTypedTextChunk(
4707 Results.getAllocator().CopyString(Overridden->getNameAsString()));
4709 bool FirstParam =
true;
4710 for (
auto *P : Method->parameters()) {
4716 Builder.AddPlaceholderChunk(
4717 Results.getAllocator().CopyString(P->getIdentifier()->getName()));
4723 Results.Ignore(Overridden);
4733 Results.EnterNewScope();
4741 SemaRef.PP.getHeaderSearchInfo().collectAllModules(Modules);
4742 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
4743 Builder.AddTypedTextChunk(
4744 Builder.getAllocator().CopyString(Modules[I]->Name));
4745 Results.AddResult(
Result(
4758 Builder.AddTypedTextChunk(
4759 Builder.getAllocator().CopyString(Submodule->Name));
4760 Results.AddResult(
Result(
4767 Results.ExitScope();
4769 Results.getCompletionContext(), Results.data(),
4778 Results.EnterNewScope();
4783 switch (CompletionContext) {
4793 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
4803 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4805 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4816 auto ThisType =
SemaRef.getCurrentThisType();
4817 if (ThisType.isNull()) {
4819 if (
auto *MethodDecl = llvm::dyn_cast_if_present<CXXMethodDecl>(
4820 SemaRef.getCurFunctionDecl()))
4821 Results.setExplicitObjectMemberFn(
4822 MethodDecl->isExplicitObjectMemberFunction());
4826 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
4830 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
4831 SemaRef.LookupVisibleDecls(S,
SemaRef.LookupOrdinaryName, Consumer,
4836 Results.ExitScope();
4838 switch (CompletionContext) {
4866 Results.getCompletionContext(), Results.data(),
4873 bool AtArgumentExpression,
bool IsSuper,
4874 ResultBuilder &Results);
4877 bool AllowNonIdentifiers,
4878 bool AllowNestedNameSpecifiers) {
4880 ResultBuilder Results(
4883 AllowNestedNameSpecifiers
4888 Results.EnterNewScope();
4891 Results.AddResult(
Result(
"const"));
4892 Results.AddResult(
Result(
"volatile"));
4894 Results.AddResult(
Result(
"restrict"));
4900 Results.AddResult(
"final");
4902 if (AllowNonIdentifiers) {
4903 Results.AddResult(
Result(
"operator"));
4907 if (AllowNestedNameSpecifiers) {
4908 Results.allowNestedNameSpecifiers();
4909 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
4910 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
4914 Results.setFilter(
nullptr);
4917 Results.ExitScope();
4923 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
4934 if (!
T.get().isNull() &&
T.get()->isObjCObjectOrInterfaceType())
4942 Results.getCompletionContext(), Results.data(),
4947 if (
Scope ==
"clang")
4955 if (
Scope ==
"_Clang")
4957 if (
Scope ==
"__gnu__")
4981 llvm::StringRef InScopeName;
4982 bool InScopeUnderscore =
false;
4984 InScopeName = InScope->
getName();
4986 InScopeName = NoUnderscore;
4987 InScopeUnderscore =
true;
4994 llvm::DenseSet<llvm::StringRef> FoundScopes;
4996 if (A.IsTargetSpecific &&
5001 for (
const auto &S : A.Spellings) {
5002 if (S.Syntax != Syntax)
5004 llvm::StringRef Name = S.NormalizedFullName;
5005 llvm::StringRef
Scope;
5008 std::tie(
Scope, Name) = Name.split(
"::");
5010 std::swap(Name,
Scope);
5016 if (!
Scope.empty() && FoundScopes.insert(
Scope).second) {
5027 if (!InScopeName.empty()) {
5028 if (
Scope != InScopeName)
5033 auto Add = [&](llvm::StringRef
Scope, llvm::StringRef Name,
5036 Results.getCodeCompletionTUInfo());
5038 if (!
Scope.empty()) {
5047 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
Text));
5049 if (!A.ArgNames.empty()) {
5052 for (
const char *Arg : A.ArgNames) {
5056 Builder.AddPlaceholderChunk(Arg);
5061 Results.AddResult(Builder.TakeString());
5068 if (!InScopeUnderscore)
5069 Add(
Scope, Name,
false);
5074 if (!(InScope && !InScopeUnderscore) && SyntaxSupportsGuards) {
5075 if (
Scope.empty()) {
5076 Add(
Scope, Name,
true);
5081 Add(GuardedScope, Name,
true);
5091 for (
const auto &Entry : ParsedAttrInfoRegistry::entries())
5092 AddCompletions(*Entry.instantiate());
5095 Results.getCompletionContext(), Results.data(),
5114struct CoveredEnumerators {
5122 const CoveredEnumerators &Enumerators) {
5124 if (Context.getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) {
5131 Results.EnterNewScope();
5132 for (
auto *E :
Enum->enumerators()) {
5133 if (Enumerators.Seen.count(E))
5137 Results.AddResult(R, CurContext,
nullptr,
false);
5139 Results.ExitScope();
5145 assert(!
T.isNull());
5158 if (
T->isPointerType())
5159 T =
T->getPointeeType();
5168 if (!Results.includeCodePatterns())
5171 Results.getCodeCompletionTUInfo());
5176 if (!Parameters.empty()) {
5185 constexpr llvm::StringLiteral NamePlaceholder =
"!#!NAME_GOES_HERE!#!";
5186 std::string
Type = std::string(NamePlaceholder);
5188 llvm::StringRef Prefix, Suffix;
5189 std::tie(Prefix, Suffix) = llvm::StringRef(
Type).split(NamePlaceholder);
5190 Prefix = Prefix.rtrim();
5191 Suffix = Suffix.ltrim();
5214 ResultBuilder Results(
5218 Data.IsParenthesized
5221 Data.PreferredType));
5224 if (
Data.ObjCCollection)
5225 Results.setFilter(&ResultBuilder::IsObjCCollection);
5226 else if (
Data.IntegralConstantExpression)
5227 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
5229 Results.setFilter(&ResultBuilder::IsOrdinaryName);
5231 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
5233 if (!
Data.PreferredType.isNull())
5234 Results.setPreferredType(
Data.PreferredType.getNonReferenceType());
5237 for (
unsigned I = 0, N =
Data.IgnoreDecls.size(); I != N; ++I)
5238 Results.Ignore(
Data.IgnoreDecls[I]);
5240 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
5241 Consumer.setIsAddressOfOperand(IsAddressOfOperand);
5246 Results.EnterNewScope();
5248 Results.ExitScope();
5250 bool PreferredTypeIsPointer =
false;
5251 if (!
Data.PreferredType.isNull()) {
5252 PreferredTypeIsPointer =
Data.PreferredType->isAnyPointerType() ||
5253 Data.PreferredType->isMemberPointerType() ||
5254 Data.PreferredType->isBlockPointerType();
5255 if (
auto *
Enum =
Data.PreferredType->getAsEnumDecl()) {
5259 CoveredEnumerators());
5264 !
Data.IntegralConstantExpression)
5269 PreferredTypeIsPointer);
5279 Results.getCompletionContext(), Results.data(),
5285 bool IsParenthesized,
5286 bool IsAddressOfOperand) {
5289 IsAddressOfOperand);
5314 if (Protocol->hasDefinition())
5315 return Protocol->getDefinition();
5329 Builder.AddResultTypeChunk(
5331 Policy, Builder.getAllocator()));
5337 Builder.AddPlaceholderChunk(
"...");
5339 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
5344 std::string PlaceholderStr =
5347 if (I == N - 1 && BlockProtoLoc &&
5349 PlaceholderStr +=
", ...";
5352 Builder.AddPlaceholderChunk(
5353 Builder.getAllocator().CopyString(PlaceholderStr));
5363 bool AllowNullaryMethods,
DeclContext *CurContext,
5365 bool IsBaseExprStatement =
false,
5366 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
5374 if (!AddedProperties.insert(P->getIdentifier()).second)
5379 if (!P->getType().getTypePtr()->isBlockPointerType() ||
5380 !IsBaseExprStatement) {
5382 Result(P, Results.getBasePriority(P), std::nullopt);
5383 if (!InOriginalClass)
5385 Results.MaybeAddResult(R, CurContext);
5397 Result(P, Results.getBasePriority(P), std::nullopt);
5398 if (!InOriginalClass)
5400 Results.MaybeAddResult(R, CurContext);
5407 Results.getCodeCompletionTUInfo());
5410 BlockLoc, BlockProtoLoc);
5411 Result R =
Result(Builder.TakeString(), P, Results.getBasePriority(P));
5412 if (!InOriginalClass)
5414 Results.MaybeAddResult(R, CurContext);
5418 if (!P->isReadOnly()) {
5420 Results.getCodeCompletionTUInfo());
5424 Builder.AddTypedTextChunk(
5425 Results.getAllocator().CopyString(P->getName()));
5430 BlockProtoLoc,
true);
5432 Builder.AddPlaceholderChunk(
5433 Builder.getAllocator().CopyString(PlaceholderStr));
5441 Result(Builder.TakeString(), P,
5442 Results.getBasePriority(P) +
5446 if (!InOriginalClass)
5448 Results.MaybeAddResult(R, CurContext);
5452 if (IsClassProperty) {
5461 if (AllowNullaryMethods) {
5466 const IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
5469 if (!AddedProperties.insert(Name).second)
5472 Results.getCodeCompletionTUInfo());
5474 Builder.AddTypedTextChunk(
5475 Results.getAllocator().CopyString(Name->
getName()));
5478 if (!InOriginalClass)
5480 Results.MaybeAddResult(R, CurContext);
5483 if (IsClassProperty) {
5484 for (
const auto *M : Container->
methods()) {
5488 if (!M->getSelector().isUnarySelector() ||
5489 M->getReturnType()->isVoidType() || M->isInstanceMethod())
5494 for (
auto *M : Container->
methods()) {
5495 if (M->getSelector().isUnarySelector())
5503 for (
auto *P : Protocol->protocols())
5505 CurContext, AddedProperties, Results,
5506 IsBaseExprStatement, IsClassProperty,
5509 dyn_cast<ObjCInterfaceDecl>(Container)) {
5510 if (AllowCategories) {
5512 for (
auto *Cat : IFace->known_categories())
5514 CurContext, AddedProperties, Results,
5515 IsBaseExprStatement, IsClassProperty,
5520 for (
auto *I : IFace->all_referenced_protocols())
5522 CurContext, AddedProperties, Results,
5523 IsBaseExprStatement, IsClassProperty,
5527 if (IFace->getSuperClass())
5529 AllowNullaryMethods, CurContext, AddedProperties,
5530 Results, IsBaseExprStatement, IsClassProperty,
5532 }
else if (
const auto *Category =
5533 dyn_cast<ObjCCategoryDecl>(Container)) {
5535 for (
auto *P : Category->protocols())
5537 CurContext, AddedProperties, Results,
5538 IsBaseExprStatement, IsClassProperty,
5547 std::optional<FixItHint> AccessOpFixIt) {
5550 Results.setObjectTypeQualifiers(BaseType.getQualifiers(), BaseKind);
5553 Results.allowNestedNameSpecifiers();
5554 std::vector<FixItHint> FixIts;
5556 FixIts.emplace_back(*AccessOpFixIt);
5557 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
5565 if (!Results.empty()) {
5569 bool IsDependent = BaseType->isDependentType();
5571 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
5589 BaseType = Resolver.
simplifyType(BaseType,
nullptr,
false);
5590 return dyn_cast_if_present<RecordDecl>(
5626 const IdentifierInfo *Name =
nullptr;
5631 std::optional<SmallVector<QualType, 1>> ArgTypes;
5633 enum AccessOperator {
5639 const TypeConstraint *ResultType =
nullptr;
5645 CodeCompletionString *render(Sema &S, CodeCompletionAllocator &Alloc,
5646 CodeCompletionTUInfo &Info)
const {
5647 CodeCompletionBuilder B(Alloc, Info);
5650 std::string AsString;
5652 llvm::raw_string_ostream
OS(AsString);
5653 QualType ExactType = deduceType(*ResultType);
5659 B.AddResultTypeChunk(
Alloc.CopyString(AsString));
5662 B.AddTypedTextChunk(
Alloc.CopyString(Name->
getName()));
5667 for (QualType Arg : *ArgTypes) {
5674 B.AddPlaceholderChunk(
Alloc.CopyString(
5679 return B.TakeString();
5686 ConceptInfo(
const TemplateTypeParmType &BaseType, Scope *S) {
5687 auto *TemplatedEntity = getTemplatedEntity(BaseType.getDecl(), S);
5688 for (
const AssociatedConstraint &AC :
5689 constraintsForTemplatedEntity(TemplatedEntity))
5690 believe(AC.ConstraintExpr, &BaseType);
5693 std::vector<Member> members() {
5694 std::vector<Member> Results;
5695 for (
const auto &E : this->Results)
5696 Results.push_back(E.second);
5697 llvm::sort(Results, [](
const Member &L,
const Member &R) {
5698 return L.Name->getName() <
R.Name->getName();
5705 void believe(
const Expr *E,
const TemplateTypeParmType *
T) {
5708 if (
auto *CSE = dyn_cast<ConceptSpecializationExpr>(E)) {
5719 ConceptDecl *CD = CSE->getNamedConcept();
5722 for (
const auto &Arg : CSE->getTemplateArguments()) {
5723 if (Index >= Params->
size())
5725 if (isApprox(Arg,
T)) {
5726 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Params->
getParam(Index));
5738 }
else if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
5741 if (BO->getOpcode() == BO_LAnd || BO->getOpcode() == BO_LOr) {
5742 believe(BO->getLHS(),
T);
5743 believe(BO->getRHS(),
T);
5745 }
else if (
auto *RE = dyn_cast<RequiresExpr>(E)) {
5747 for (
const concepts::Requirement *Req : RE->getRequirements()) {
5748 if (!Req->isDependent())
5752 if (
auto *TR = dyn_cast<concepts::TypeRequirement>(Req)) {
5754 QualType AssertedType = TR->getType()->getType();
5755 ValidVisitor(
this,
T).TraverseType(AssertedType);
5756 }
else if (
auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
5757 ValidVisitor Visitor(
this,
T);
5761 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
5763 ER->getReturnTypeRequirement().getTypeConstraint();
5764 Visitor.OuterExpr = ER->getExpr();
5766 Visitor.TraverseStmt(ER->getExpr());
5767 }
else if (
auto *NR = dyn_cast<concepts::NestedRequirement>(Req)) {
5768 believe(NR->getConstraintExpr(),
T);
5778 const TemplateTypeParmType *
T;
5780 CallExpr *Caller =
nullptr;
5785 Expr *OuterExpr =
nullptr;
5786 const TypeConstraint *OuterType =
nullptr;
5788 ValidVisitor(ConceptInfo *Outer,
const TemplateTypeParmType *
T)
5789 : Outer(Outer),
T(
T) {
5795 VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E)
override {
5798 if (
Base->isPointerType() && IsArrow) {
5800 Base =
Base->getPointeeType().getTypePtr();
5802 if (isApprox(Base,
T))
5803 addValue(E, E->
getMember(), IsArrow ? Member::Arrow : Member::Dot);
5808 bool VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E)
override {
5810 if (
Qualifier.getKind() == NestedNameSpecifier::Kind::Type &&
5817 bool VisitDependentNameType(DependentNameType *DNT)
override {
5818 NestedNameSpecifier Q = DNT->getQualifier();
5819 if (Q.
getKind() == NestedNameSpecifier::Kind::Type &&
5821 addType(DNT->getIdentifier());
5830 if (NNS.
getKind() == NestedNameSpecifier::Kind::Type) {
5832 if (NestedNameSpecifier Q = NNST->
getPrefix();
5833 Q.
getKind() == NestedNameSpecifier::Kind::Type &&
5835 if (
const auto *DNT = dyn_cast_or_null<DependentNameType>(NNST))
5836 addType(DNT->getIdentifier());
5847 bool VisitCallExpr(CallExpr *CE)
override {
5854 void addResult(
Member &&M) {
5855 auto R = Outer->Results.try_emplace(M.Name);
5860 std::make_tuple(M.ArgTypes.has_value(), M.ResultType !=
nullptr,
5861 M.Operator) > std::make_tuple(O.ArgTypes.has_value(),
5862 O.ResultType !=
nullptr,
5867 void addType(
const IdentifierInfo *Name) {
5872 M.Operator = Member::Colons;
5873 addResult(std::move(M));
5876 void addValue(Expr *E, DeclarationName Name,
5877 Member::AccessOperator Operator) {
5882 Result.Operator = Operator;
5885 if (Caller !=
nullptr && Callee == E) {
5886 Result.ArgTypes.emplace();
5887 for (
const auto *Arg : Caller->
arguments())
5888 Result.ArgTypes->push_back(Arg->getType());
5889 if (Caller == OuterExpr) {
5890 Result.ResultType = OuterType;
5894 Result.ResultType = OuterType;
5896 addResult(std::move(
Result));
5900 static bool isApprox(
const TemplateArgument &Arg,
const Type *
T) {
5905 static bool isApprox(
const Type *T1,
const Type *T2) {
5914 static DeclContext *getTemplatedEntity(
const TemplateTypeParmDecl *D,
5918 Scope *Inner =
nullptr;
5921 return Inner ? Inner->
getEntity() :
nullptr;
5930 static SmallVector<AssociatedConstraint, 1>
5931 constraintsForTemplatedEntity(DeclContext *DC) {
5932 SmallVector<AssociatedConstraint, 1>
Result;
5937 TD->getAssociatedConstraints(
Result);
5939 if (
const auto *CTPSD =
5940 dyn_cast<ClassTemplatePartialSpecializationDecl>(DC))
5941 CTPSD->getAssociatedConstraints(
Result);
5942 if (
const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl>(DC))
5943 VTPSD->getAssociatedConstraints(
Result);
5949 static QualType deduceType(
const TypeConstraint &
T) {
5952 DeclarationName DN =
T.getNamedConcept()->getDeclName();
5954 if (
const auto *Args =
T.getTemplateArgsAsWritten())
5955 if (Args->getNumTemplateArgs() == 1) {
5956 const auto &Arg = Args->arguments().front().getArgument();
5963 llvm::DenseMap<const IdentifierInfo *, Member> Results;
5970QualType getApproximateType(
const Expr *E, HeuristicResolver &Resolver) {
5984Expr *unwrapParenList(Expr *Base) {
5985 if (
auto *PLE = llvm::dyn_cast_or_null<ParenListExpr>(Base)) {
5986 if (PLE->getNumExprs() == 0)
5988 Base = PLE->getExpr(PLE->getNumExprs() - 1);
5997 bool IsBaseExprStatement,
QualType PreferredType) {
5999 OtherOpBase = unwrapParenList(OtherOpBase);
6004 SemaRef.PerformMemberExprBaseConversion(
Base, IsArrow);
6008 getApproximateType(ConvertedBase.
get(),
Resolver);
6014 !PointeeType.isNull()) {
6015 ConvertedBaseType = PointeeType;
6034 &ResultBuilder::IsMember);
6036 auto DoCompletion = [&](
Expr *
Base,
bool IsArrow,
6037 std::optional<FixItHint> AccessOpFixIt) ->
bool {
6042 SemaRef.PerformMemberExprBaseConversion(
Base, IsArrow);
6048 if (BaseType.isNull())
6054 !PointeeType.isNull()) {
6055 BaseType = PointeeType;
6057 }
else if (BaseType->isObjCObjectPointerType() ||
6058 BaseType->isTemplateTypeParmType()) {
6067 RD, std::move(AccessOpFixIt));
6068 }
else if (
const auto *TTPT =
6069 dyn_cast<TemplateTypeParmType>(BaseType.getTypePtr())) {
6071 IsArrow ? ConceptInfo::Member::Arrow : ConceptInfo::Member::Dot;
6072 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
6073 if (R.Operator != Operator)
6079 Result.FixIts.push_back(*AccessOpFixIt);
6080 Results.AddResult(std::move(
Result));
6082 }
else if (!IsArrow && BaseType->isObjCObjectPointerType()) {
6086 if (AccessOpFixIt) {
6094 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
6097 AddedProperties, Results, IsBaseExprStatement);
6103 SemaRef.CurContext, AddedProperties, Results,
6104 IsBaseExprStatement,
false,
6106 }
else if ((IsArrow && BaseType->isObjCObjectPointerType()) ||
6107 (!IsArrow && BaseType->isObjCObjectType())) {
6111 if (AccessOpFixIt) {
6117 Class = ObjCPtr->getInterfaceDecl();
6123 CodeCompletionDeclConsumer Consumer(Results,
Class, BaseType);
6124 Results.setFilter(&ResultBuilder::IsObjCIvar);
6136 Results.EnterNewScope();
6138 bool CompletionSucceded = DoCompletion(
Base, IsArrow, std::nullopt);
6142 CompletionSucceded |= DoCompletion(
6143 OtherOpBase, !IsArrow,
6147 Results.ExitScope();
6149 if (!CompletionSucceded)
6154 Results.getCompletionContext(), Results.data(),
6160 bool IsBaseExprStatement) {
6163 SemaRef.ObjC().getObjCInterfaceDecl(ClassNamePtr, ClassNameLoc);
6170 &ResultBuilder::IsMember);
6171 Results.EnterNewScope();
6175 AddedProperties, Results, IsBaseExprStatement,
6177 Results.ExitScope();
6179 Results.getCompletionContext(), Results.data(),
6187 ResultBuilder::LookupFilter Filter =
nullptr;
6192 Filter = &ResultBuilder::IsEnum;
6197 Filter = &ResultBuilder::IsUnion;
6204 Filter = &ResultBuilder::IsClassOrStruct;
6209 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
6214 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
6217 Results.setFilter(Filter);
6224 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
6231 Results.getCompletionContext(), Results.data(),
6238 Results.AddResult(
"const");
6240 Results.AddResult(
"volatile");
6242 Results.AddResult(
"restrict");
6244 Results.AddResult(
"_Atomic");
6246 Results.AddResult(
"__unaligned");
6253 Results.EnterNewScope();
6255 Results.ExitScope();
6257 Results.getCompletionContext(), Results.data(),
6266 Results.EnterNewScope();
6269 Results.AddResult(
"noexcept");
6273 Results.AddResult(
"final");
6275 Results.AddResult(
"override");
6278 Results.ExitScope();
6280 Results.getCompletionContext(), Results.data(),
6293 SemaRef.getCurFunction()->SwitchStack.back().getPointer();
6301 Data.IntegralConstantExpression =
true;
6310 CoveredEnumerators Enumerators;
6312 SC = SC->getNextSwitchCase()) {
6313 CaseStmt *Case = dyn_cast<CaseStmt>(SC);
6318 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
6320 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
6340 Enumerators.SuggestedQualifier = DRE->getQualifier();
6355 Results.getCompletionContext(), Results.data(),
6360 if (Args.size() && !Args.data())
6363 for (
unsigned I = 0; I != Args.size(); ++I)
6384 if (Candidate.Function) {
6385 if (Candidate.Function->isDeleted())
6388 Candidate.Function) &&
6389 Candidate.Function->getNumParams() <= ArgSize &&
6398 if (Candidate.Viable)
6412 for (
auto &Candidate : Candidates) {
6413 QualType CandidateParamType = Candidate.getParamType(N);
6414 if (CandidateParamType.
isNull())
6416 if (ParamType.
isNull()) {
6417 ParamType = CandidateParamType;
6434 if (Candidates.empty())
6438 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc,
6446 Fn = unwrapParenList(Fn);
6457 auto ArgsWithoutDependentTypes =
6462 Expr *NakedFn = Fn->IgnoreParenCasts();
6468 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
6469 SemaRef.AddOverloadedCallCandidates(ULE, ArgsWithoutDependentTypes,
6472 }
else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
6474 if (UME->hasExplicitTemplateArgs()) {
6475 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
6476 TemplateArgs = &TemplateArgsBuffer;
6481 1, UME->isImplicitAccess() ?
nullptr : UME->getBase());
6482 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6483 ArgsWithoutDependentTypes.end());
6485 Decls.
append(UME->decls_begin(), UME->decls_end());
6486 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
6487 SemaRef.AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
6490 FirstArgumentIsBase);
6493 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
6494 FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl());
6495 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
6496 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
6502 SemaRef.AddOverloadCandidate(FD,
6504 ArgsWithoutDependentTypes, CandidateSet,
6514 getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
6516 SemaRef.LookupQualifiedName(R, DC);
6517 R.suppressDiagnostics();
6519 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6520 ArgsWithoutDependentTypes.end());
6521 SemaRef.AddFunctionCandidates(R.asUnresolvedSet(), ArgExprs,
6533 if (!
T->getPointeeType().isNull())
6534 T =
T->getPointeeType();
6537 if (!
SemaRef.TooManyArguments(FP->getNumParams(),
6538 ArgsWithoutDependentTypes.size(),
6574static std::optional<unsigned>
6577 static constexpr unsigned Invalid = std::numeric_limits<unsigned>::max();
6583 unsigned ArgsAfterDesignator = 0;
6584 for (
const Expr *Arg : Args) {
6585 if (
const auto *DIE = dyn_cast<DesignatedInitExpr>(Arg)) {
6586 if (DIE->size() == 1 && DIE->getDesignator(0)->isFieldDesignator()) {
6587 DesignatedFieldName = DIE->getDesignator(0)->getFieldName();
6588 ArgsAfterDesignator = 0;
6595 ++ArgsAfterDesignator;
6598 if (!DesignatedFieldName)
6599 return std::nullopt;
6603 unsigned DesignatedIndex = 0;
6604 const FieldDecl *DesignatedField =
nullptr;
6605 for (
const auto *Field :
Aggregate.getAggregate()->fields()) {
6606 if (Field->getIdentifier() == DesignatedFieldName) {
6607 DesignatedField = Field;
6612 if (!DesignatedField)
6616 unsigned AggregateSize =
Aggregate.getNumParams();
6617 while (DesignatedIndex < AggregateSize &&
6618 Aggregate.getParamDecl(DesignatedIndex) != DesignatedField)
6622 return DesignatedIndex + ArgsAfterDesignator + 1;
6645 if (Braced && !RD->
isUnion() &&
6650 if (
auto NextIndex =
6653 if (*NextIndex >= AggregateSize)
6655 Results.push_back(AggregateSig);
6661 if (Args.size() < AggregateSize)
6662 Results.push_back(AggregateSig);
6672 if (
auto *FD = dyn_cast<FunctionDecl>(
C)) {
6676 SemaRef.isInitListConstructor(FD))
6683 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
6685 SemaRef.isInitListConstructor(FTD->getTemplatedDecl()))
6688 SemaRef.AddTemplateOverloadCandidate(
6690 nullptr, Args, CandidateSet,
6711 dyn_cast<CXXConstructorDecl>(ConstructorDecl);
6716 Constructor->getParent(), SS, TemplateTypeTy, II))
6718 MemberDecl->getLocation(), ArgExprs,
6719 OpenParLoc, Braced);
6727 if (Index < Params.
size())
6730 Param = Params.
asArray().back();
6736 return llvm::isa<TemplateTypeParmDecl>(Param);
6738 return llvm::isa<NonTypeTemplateParmDecl>(Param);
6740 return llvm::isa<TemplateTemplateParmDecl>(Param);
6742 llvm_unreachable(
"Unhandled switch case");
6754 bool Matches =
true;
6755 for (
unsigned I = 0; I < Args.size(); ++I) {
6762 Results.emplace_back(TD);
6766 if (
const auto *TD =
Template.getAsTemplateDecl()) {
6768 }
else if (
const auto *OTS =
Template.getAsOverloadedTemplate()) {
6770 if (
const auto *TD = llvm::dyn_cast<TemplateDecl>(ND))
6781 if (
const auto *FD = llvm::dyn_cast<FieldDecl>(
Member))
6783 if (
const auto *IFD = llvm::dyn_cast<IndirectFieldDecl>(
Member))
6784 return IFD->getAnonField();
6795 if (BaseType.isNull())
6799 if (D.isArrayDesignator() || D.isArrayRangeDesignator()) {
6800 if (BaseType->isDependentType()) {
6801 BaseType = Context.DependentTy;
6804 const ArrayType *AT = Context.getAsArrayType(BaseType);
6811 assert(D.isFieldDesignator());
6812 if (BaseType->isDependentType()) {
6813 BaseType = Context.DependentTy;
6821 const FieldDecl *MemberDecl = LookupField(RD, D);
6834 if (BaseType.isNull())
6837 if (!RD || RD->fields().empty())
6845 Results.EnterNewScope();
6846 for (
const Decl *D : RD->decls()) {
6848 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(D))
6849 FD = IFD->getAnonField();
6850 else if (
auto *DFD = dyn_cast<FieldDecl>(D))
6857 ResultBuilder::Result
Result(FD, Results.getBasePriority(FD));
6860 Results.ExitScope();
6862 Results.getCompletionContext(), Results.data(),
6874 SemaRef.LookupQualifiedName(R, RD);
6879 if (
auto *FD = dyn_cast<FieldDecl>(ND))
6881 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(ND))
6882 return IFD->getAnonField();
6888 if (BaseType.isNull())
6899 &ResultBuilder::IsOffsetofField);
6901 Results.EnterNewScope();
6902 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType);
6910 Results.ExitScope();
6913 Results.getCompletionContext(), Results.data(),
6918 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
6927 Data.IgnoreDecls.push_back(VD);
6937 Results.getCodeCompletionTUInfo());
6939 if (!AfterExclaim) {
6940 if (Results.includeCodePatterns()) {
6941 Builder.AddTypedTextChunk(
"constexpr");
6944 Builder.AddPlaceholderChunk(
"condition");
6949 Builder.AddPlaceholderChunk(
"statements");
6952 Results.AddResult({Builder.TakeString()});
6954 Results.AddResult({
"constexpr"});
6959 if (Results.includeCodePatterns()) {
6960 Builder.AddTypedTextChunk(
"consteval");
6964 Builder.AddPlaceholderChunk(
"statements");
6967 Results.AddResult({Builder.TakeString()});
6969 Results.AddResult({
"consteval"});
6974 Results.getCompletionContext(), Results.data(),
6982 Results.setFilter(&ResultBuilder::IsOrdinaryName);
6983 Results.EnterNewScope();
6985 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
6994 Results.getCodeCompletionTUInfo());
6996 auto AddElseBodyPattern = [&] {
7001 Builder.AddPlaceholderChunk(
"statements");
7007 Builder.AddPlaceholderChunk(
"statement");
7011 Builder.AddTypedTextChunk(
"else");
7012 if (Results.includeCodePatterns())
7013 AddElseBodyPattern();
7014 Results.AddResult(Builder.TakeString());
7017 Builder.AddTypedTextChunk(
"else if");
7021 Builder.AddPlaceholderChunk(
"condition");
7023 Builder.AddPlaceholderChunk(
"expression");
7025 if (Results.includeCodePatterns()) {
7026 AddElseBodyPattern();
7028 Results.AddResult(Builder.TakeString());
7030 Results.ExitScope();
7039 Results.getCompletionContext(), Results.data(),
7045 bool IsAddressOfOperand,
bool IsInDeclarationContext,
QualType BaseType,
7064 if (!PreferredType.
isNull())
7065 DummyResults.setPreferredType(PreferredType);
7067 CodeCompletionDeclConsumer Consumer(DummyResults, S->
getEntity(),
7074 DummyResults.getCompletionContext(),
nullptr, 0);
7081 std::optional<Sema::ContextRAII> SimulateContext;
7084 if (IsInDeclarationContext && Ctx !=
nullptr)
7085 SimulateContext.emplace(
SemaRef, Ctx);
7091 if (Ctx ==
nullptr ||
SemaRef.RequireCompleteDeclContext(SS, Ctx))
7097 if (!PreferredType.
isNull())
7098 Results.setPreferredType(PreferredType);
7099 Results.EnterNewScope();
7105 Results.AddResult(
"template");
7110 if (
const auto *TTPT = dyn_cast<TemplateTypeParmType>(NNS.
getAsType())) {
7111 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
7112 if (R.Operator != ConceptInfo::Member::Colons)
7126 if (Ctx && !EnteringContext)
7128 Results.ExitScope();
7132 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
7133 Consumer.setIsInDeclarationContext(IsInDeclarationContext);
7134 Consumer.setIsAddressOfOperand(IsAddressOfOperand);
7140 SimulateContext.reset();
7142 Results.getCompletionContext(), Results.data(),
7153 Context.setIsUsingDeclaration(
true);
7157 &ResultBuilder::IsNestedNameSpecifier);
7158 Results.EnterNewScope();
7166 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7170 Results.ExitScope();
7173 Results.getCompletionContext(), Results.data(),
7186 &ResultBuilder::IsNamespaceOrAlias);
7187 Results.EnterNewScope();
7188 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7192 Results.ExitScope();
7194 Results.getCompletionContext(), Results.data(),
7206 bool SuppressedGlobalResults =
7211 SuppressedGlobalResults
7214 &ResultBuilder::IsNamespace);
7216 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
7221 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
7226 OrigToLatest[NS->getFirstDecl()] = *NS;
7230 Results.EnterNewScope();
7231 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
7232 NS = OrigToLatest.begin(),
7233 NSEnd = OrigToLatest.end();
7238 SemaRef.CurContext,
nullptr,
false);
7239 Results.ExitScope();
7243 Results.getCompletionContext(), Results.data(),
7255 &ResultBuilder::IsNamespaceOrAlias);
7256 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7261 Results.getCompletionContext(), Results.data(),
7273 &ResultBuilder::IsType);
7274 Results.EnterNewScope();
7278#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
7279 if (OO_##Name != OO_Conditional) \
7280 Results.AddResult(Result(Spelling));
7281#include "clang/Basic/OperatorKinds.def"
7284 Results.allowNestedNameSpecifiers();
7285 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
7292 Results.ExitScope();
7295 Results.getCompletionContext(), Results.data(),
7304 SemaRef.AdjustDeclIfTemplate(ConstructorD);
7306 auto *
Constructor = dyn_cast<CXXConstructorDecl>(ConstructorD);
7313 Results.EnterNewScope();
7318 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
7319 if (Initializers[I]->isBaseInitializer())
7321 QualType(Initializers[I]->getBaseClass(), 0)));
7323 InitializedFields.insert(
7329 bool SawLastInitializer = Initializers.empty();
7332 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
7334 Results.getCodeCompletionTUInfo());
7335 Builder.AddTypedTextChunk(Name);
7337 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND))
7339 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
7341 FunTemplDecl->getTemplatedDecl(), Builder);
7343 return Builder.TakeString();
7345 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
7348 Results.getCodeCompletionTUInfo());
7349 Builder.AddTypedTextChunk(Name);
7351 Builder.AddPlaceholderChunk(
Type);
7355 Builder.TakeString(), ND,
7359 return Results.AddResult(CCR);
7362 Builder.TakeString(),
7365 auto AddCtorsWithName = [&](
const CXXRecordDecl *RD,
unsigned int Priority,
7366 const char *Name,
const FieldDecl *FD) {
7368 return AddDefaultCtorInit(Name,
7369 FD ? Results.getAllocator().CopyString(
7370 FD->getType().getAsString(Policy))
7374 if (Ctors.begin() == Ctors.end())
7375 return AddDefaultCtorInit(Name, Name, RD);
7379 Results.AddResult(CCR);
7383 const char *BaseName =
7384 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
7385 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
7390 auto AddField = [&](
const FieldDecl *FD) {
7391 const char *FieldName =
7392 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
7393 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
7399 for (
const auto &
Base : ClassDecl->
bases()) {
7400 if (!InitializedBases
7403 SawLastInitializer =
7404 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7406 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7411 SawLastInitializer =
false;
7415 for (
const auto &
Base : ClassDecl->
vbases()) {
7416 if (!InitializedBases
7419 SawLastInitializer =
7420 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7422 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7427 SawLastInitializer =
false;
7431 for (
auto *Field : ClassDecl->
fields()) {
7432 if (!InitializedFields.insert(
cast<FieldDecl>(Field->getCanonicalDecl()))
7434 SawLastInitializer = !Initializers.empty() &&
7435 Initializers.back()->isAnyMemberInitializer() &&
7436 Initializers.back()->getAnyMember() == Field;
7440 if (!Field->getDeclName())
7444 SawLastInitializer =
false;
7446 Results.ExitScope();
7449 Results.getCompletionContext(), Results.data(),
7464 bool AfterAmpersand) {
7468 Results.EnterNewScope();
7472 bool IncludedThis =
false;
7475 IncludedThis =
true;
7484 for (
const auto *D : S->
decls()) {
7485 const auto *Var = dyn_cast<VarDecl>(D);
7486 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
7489 if (Known.insert(Var->getIdentifier()).second)
7491 SemaRef.CurContext,
nullptr,
false);
7499 Results.ExitScope();
7502 Results.getCompletionContext(), Results.data(),
7512 auto ShouldAddDefault = [&D,
this]() {
7524 auto Op = Id.OperatorFunctionId.Operator;
7527 if (Op == OverloadedOperatorKind::OO_Equal)
7530 (Op == OverloadedOperatorKind::OO_EqualEqual ||
7531 Op == OverloadedOperatorKind::OO_ExclaimEqual ||
7532 Op == OverloadedOperatorKind::OO_Less ||
7533 Op == OverloadedOperatorKind::OO_LessEqual ||
7534 Op == OverloadedOperatorKind::OO_Greater ||
7535 Op == OverloadedOperatorKind::OO_GreaterEqual ||
7536 Op == OverloadedOperatorKind::OO_Spaceship))
7542 Results.EnterNewScope();
7543 if (ShouldAddDefault())
7544 Results.AddResult(
"default");
7547 Results.AddResult(
"delete");
7548 Results.ExitScope();
7550 Results.getCompletionContext(), Results.data(),
7556#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
7559 ResultBuilder &Results,
bool NeedAt) {
7565 Results.getCodeCompletionTUInfo());
7566 if (LangOpts.ObjC) {
7570 Builder.AddPlaceholderChunk(
"property");
7571 Results.AddResult(
Result(Builder.TakeString()));
7576 Builder.AddPlaceholderChunk(
"property");
7577 Results.AddResult(
Result(Builder.TakeString()));
7582 ResultBuilder &Results,
bool NeedAt) {
7588 if (LangOpts.ObjC) {
7603 Results.getCodeCompletionTUInfo());
7608 Builder.AddPlaceholderChunk(
"name");
7609 Results.AddResult(
Result(Builder.TakeString()));
7611 if (Results.includeCodePatterns()) {
7617 Builder.AddPlaceholderChunk(
"class");
7618 Results.AddResult(
Result(Builder.TakeString()));
7623 Builder.AddPlaceholderChunk(
"protocol");
7624 Results.AddResult(
Result(Builder.TakeString()));
7629 Builder.AddPlaceholderChunk(
"class");
7630 Results.AddResult(
Result(Builder.TakeString()));
7634 Builder.AddTypedTextChunk(
7637 Builder.AddPlaceholderChunk(
"alias");
7639 Builder.AddPlaceholderChunk(
"class");
7640 Results.AddResult(
Result(Builder.TakeString()));
7642 if (Results.getSema().getLangOpts().Modules) {
7646 Builder.AddPlaceholderChunk(
"module");
7647 Results.AddResult(
Result(Builder.TakeString()));
7655 Results.EnterNewScope();
7658 else if (
SemaRef.CurContext->isObjCContainer())
7662 Results.ExitScope();
7664 Results.getCompletionContext(), Results.data(),
7671 Results.getCodeCompletionTUInfo());
7674 const char *EncodeType =
"char[]";
7675 if (Results.getSema().getLangOpts().CPlusPlus ||
7676 Results.getSema().getLangOpts().ConstStrings)
7677 EncodeType =
"const char[]";
7678 Builder.AddResultTypeChunk(EncodeType);
7681 Builder.AddPlaceholderChunk(
"type-name");
7683 Results.AddResult(
Result(Builder.TakeString()));
7686 Builder.AddResultTypeChunk(
"Protocol *");
7689 Builder.AddPlaceholderChunk(
"protocol-name");
7691 Results.AddResult(
Result(Builder.TakeString()));
7694 Builder.AddResultTypeChunk(
"SEL");
7697 Builder.AddPlaceholderChunk(
"selector");
7699 Results.AddResult(
Result(Builder.TakeString()));
7702 Builder.AddResultTypeChunk(
"NSString *");
7704 Builder.AddPlaceholderChunk(
"string");
7705 Builder.AddTextChunk(
"\"");
7706 Results.AddResult(
Result(Builder.TakeString()));
7709 Builder.AddResultTypeChunk(
"NSArray *");
7711 Builder.AddPlaceholderChunk(
"objects, ...");
7713 Results.AddResult(
Result(Builder.TakeString()));
7716 Builder.AddResultTypeChunk(
"NSDictionary *");
7718 Builder.AddPlaceholderChunk(
"key");
7721 Builder.AddPlaceholderChunk(
"object, ...");
7723 Results.AddResult(
Result(Builder.TakeString()));
7726 Builder.AddResultTypeChunk(
"id");
7728 Builder.AddPlaceholderChunk(
"expression");
7730 Results.AddResult(
Result(Builder.TakeString()));
7736 Results.getCodeCompletionTUInfo());
7738 if (Results.includeCodePatterns()) {
7743 Builder.AddPlaceholderChunk(
"statements");
7745 Builder.AddTextChunk(
"@catch");
7747 Builder.AddPlaceholderChunk(
"parameter");
7750 Builder.AddPlaceholderChunk(
"statements");
7752 Builder.AddTextChunk(
"@finally");
7754 Builder.AddPlaceholderChunk(
"statements");
7756 Results.AddResult(
Result(Builder.TakeString()));
7762 Builder.AddPlaceholderChunk(
"expression");
7763 Results.AddResult(
Result(Builder.TakeString()));
7765 if (Results.includeCodePatterns()) {
7770 Builder.AddPlaceholderChunk(
"expression");
7773 Builder.AddPlaceholderChunk(
"statements");
7775 Results.AddResult(
Result(Builder.TakeString()));
7780 ResultBuilder &Results,
bool NeedAt) {
7793 Results.EnterNewScope();
7795 Results.ExitScope();
7797 Results.getCompletionContext(), Results.data(),
7805 Results.EnterNewScope();
7808 Results.ExitScope();
7810 Results.getCompletionContext(), Results.data(),
7818 Results.EnterNewScope();
7820 Results.ExitScope();
7822 Results.getCompletionContext(), Results.data(),
7830 if (Attributes & NewFlag)
7833 Attributes |= NewFlag;
7841 unsigned AssignCopyRetMask =
7847 if (AssignCopyRetMask &&
7869 Results.EnterNewScope();
7906 Results.getCodeCompletionTUInfo());
7915 Results.getCodeCompletionTUInfo());
7928 Results.ExitScope();
7930 Results.getCompletionContext(), Results.data(),
7944 bool AllowSameLength =
true) {
7945 unsigned NumSelIdents = SelIdents.size();
7958 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
7961 for (
unsigned I = 0; I != NumSelIdents; ++I)
7971 bool AllowSameLength =
true) {
8005 ResultBuilder &Results,
bool InOriginalClass =
true,
8006 bool IsRootClass =
false) {
8010 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
8014 if (M->isInstanceMethod() == WantInstanceMethods ||
8015 (IsRootClass && !WantInstanceMethods)) {
8021 if (!Selectors.insert(M->getSelector()).second)
8025 Result(M, Results.getBasePriority(M), std::nullopt);
8026 R.StartParameter = SelIdents.size();
8027 R.AllParametersAreInformative = (WantKind !=
MK_Any);
8028 if (!InOriginalClass)
8030 Results.MaybeAddResult(R, CurContext);
8035 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
8036 if (Protocol->hasDefinition()) {
8038 Protocol->getReferencedProtocols();
8040 E = Protocols.
end();
8042 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
8043 Selectors, AllowSameLength, Results,
false, IsRootClass);
8052 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
8053 Selectors, AllowSameLength, Results,
false, IsRootClass);
8057 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
8058 CurContext, Selectors, AllowSameLength, Results,
8059 InOriginalClass, IsRootClass);
8063 CatDecl->getReferencedProtocols();
8065 E = Protocols.
end();
8067 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
8068 Selectors, AllowSameLength, Results,
false, IsRootClass);
8072 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
8073 Selectors, AllowSameLength, Results, InOriginalClass,
8081 SelIdents, CurContext, Selectors, AllowSameLength, Results,
8086 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
8087 Selectors, AllowSameLength, Results, InOriginalClass,
8094 dyn_cast_or_null<ObjCInterfaceDecl>(
SemaRef.CurContext);
8097 dyn_cast_or_null<ObjCCategoryDecl>(
SemaRef.CurContext))
8098 Class = Category->getClassInterface();
8108 Results.EnterNewScope();
8114 Results.ExitScope();
8116 Results.getCompletionContext(), Results.data(),
8123 dyn_cast_or_null<ObjCInterfaceDecl>(
SemaRef.CurContext);
8126 dyn_cast_or_null<ObjCCategoryDecl>(
SemaRef.CurContext))
8127 Class = Category->getClassInterface();
8137 Results.EnterNewScope();
8144 Results.ExitScope();
8146 Results.getCompletionContext(), Results.data(),
8155 Results.EnterNewScope();
8158 bool AddedInOut =
false;
8161 Results.AddResult(
"in");
8162 Results.AddResult(
"inout");
8167 Results.AddResult(
"out");
8169 Results.AddResult(
"inout");
8174 Results.AddResult(
"bycopy");
8175 Results.AddResult(
"byref");
8176 Results.AddResult(
"oneway");
8179 Results.AddResult(
"nonnull");
8180 Results.AddResult(
"nullable");
8181 Results.AddResult(
"null_unspecified");
8189 SemaRef.PP.isMacroDefined(
"IBAction")) {
8191 Results.getCodeCompletionTUInfo(),
8193 Builder.AddTypedTextChunk(
"IBAction");
8195 Builder.AddPlaceholderChunk(
"selector");
8198 Builder.AddTextChunk(
"id");
8200 Builder.AddTextChunk(
"sender");
8211 Results.ExitScope();
8214 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
8215 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
8224 Results.getCompletionContext(), Results.data(),
8233 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(E);
8251 switch (Msg->getReceiverKind()) {
8255 IFace = ObjType->getInterface();
8259 QualType T = Msg->getInstanceReceiver()->getType();
8261 IFace = Ptr->getInterfaceDecl();
8274 if (Method->isInstanceMethod())
8275 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
8276 .Case(
"retain", IFace)
8277 .Case(
"strong", IFace)
8278 .Case(
"autorelease", IFace)
8279 .Case(
"copy", IFace)
8280 .Case(
"copyWithZone", IFace)
8281 .Case(
"mutableCopy", IFace)
8282 .Case(
"mutableCopyWithZone", IFace)
8283 .Case(
"awakeFromCoder", IFace)
8284 .Case(
"replacementObjectFromCoder", IFace)
8285 .Case(
"class", IFace)
8286 .Case(
"classForCoder", IFace)
8287 .Case(
"superclass", Super)
8290 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
8292 .Case(
"alloc", IFace)
8293 .Case(
"allocWithZone", IFace)
8294 .Case(
"class", IFace)
8295 .Case(
"superclass", Super)
8315static ObjCMethodDecl *
8318 ResultBuilder &Results) {
8329 while ((Class = Class->getSuperClass()) && !SuperMethod) {
8331 SuperMethod = Class->getMethod(CurMethod->
getSelector(),
8336 for (
const auto *Cat : Class->known_categories()) {
8337 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
8355 CurP != CurPEnd; ++CurP, ++SuperP) {
8358 (*SuperP)->getType()))
8362 if (!(*CurP)->getIdentifier())
8368 Results.getCodeCompletionTUInfo());
8372 Results.getCompletionContext().getBaseType(), Builder);
8375 if (NeedSuperKeyword) {
8376 Builder.AddTypedTextChunk(
"super");
8382 if (NeedSuperKeyword)
8383 Builder.AddTextChunk(
8386 Builder.AddTypedTextChunk(
8390 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
8391 if (I > SelIdents.size())
8394 if (I < SelIdents.size())
8395 Builder.AddInformativeChunk(
8397 else if (NeedSuperKeyword || I > SelIdents.size()) {
8398 Builder.AddTextChunk(
8400 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8401 (*CurP)->getIdentifier()->getName()));
8403 Builder.AddTypedTextChunk(
8405 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8406 (*CurP)->getIdentifier()->getName()));
8418 ResultBuilder Results(
8423 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
8424 : &ResultBuilder::IsObjCMessageReceiver);
8426 CodeCompletionDeclConsumer Consumer(Results,
SemaRef.CurContext);
8427 Results.EnterNewScope();
8436 if (Iface->getSuperClass()) {
8437 Results.AddResult(
Result(
"super"));
8445 Results.ExitScope();
8450 Results.getCompletionContext(), Results.data(),
8460 CDecl = CurMethod->getClassInterface();
8469 if (CurMethod->isInstanceMethod()) {
8474 AtArgumentExpression, CDecl);
8484 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
8486 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
8488 getASTContext().getTypeDeclType(TD)->getAs<ObjCObjectType>())
8489 CDecl = Iface->getInterface();
8499 SemaRef.ActOnIdExpression(S, SS, TemplateKWLoc,
id,
8503 SelIdents, AtArgumentExpression);
8513 AtArgumentExpression,
8520 unsigned NumSelIdents) {
8522 ASTContext &Context = Results.getSema().Context;
8526 Result *ResultsData = Results.data();
8527 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
8528 Result &R = ResultsData[I];
8529 if (R.Kind == Result::RK_Declaration &&
8531 if (R.Priority <= BestPriority) {
8533 if (NumSelIdents <= Method->param_size()) {
8535 Method->parameters()[NumSelIdents - 1]->getType();
8536 if (R.Priority < BestPriority || PreferredType.
isNull()) {
8537 BestPriority = R.Priority;
8538 PreferredType = MyPreferredType;
8539 }
else if (!Context.hasSameUnqualifiedType(PreferredType,
8548 return PreferredType;
8554 bool AtArgumentExpression,
bool IsSuper,
8555 ResultBuilder &Results) {
8570 Results.EnterNewScope();
8577 Results.Ignore(SuperMethod);
8583 Results.setPreferredSelector(CurMethod->getSelector());
8588 Selectors, AtArgumentExpression, Results);
8606 for (SemaObjC::GlobalMethodPool::iterator
8611 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
8615 Result R(MethList->getMethod(),
8616 Results.getBasePriority(MethList->getMethod()),
8618 R.StartParameter = SelIdents.size();
8619 R.AllParametersAreInformative =
false;
8620 Results.MaybeAddResult(R, SemaRef.
CurContext);
8625 Results.ExitScope();
8630 bool AtArgumentExpression,
bool IsSuper) {
8634 ResultBuilder Results(
8641 AtArgumentExpression, IsSuper, Results);
8648 if (AtArgumentExpression) {
8651 if (PreferredType.
isNull())
8659 Results.getCompletionContext(), Results.data(),
8680 RecExpr = Conv.
get();
8684 : Super ? Context.getObjCObjectPointerType(
8685 Context.getObjCInterfaceType(Super))
8686 : Context.getObjCIdType();
8696 AtArgumentExpression, Super);
8699 Context.getObjCObjectPointerType(Context.getObjCInterfaceType(IFace));
8704 RecExpr = Conv.
get();
8705 ReceiverType = RecExpr->
getType();
8710 ResultBuilder Results(
8714 ReceiverType, SelIdents));
8716 Results.EnterNewScope();
8723 Results.Ignore(SuperMethod);
8729 Results.setPreferredSelector(CurMethod->getSelector());
8742 Selectors, AtArgumentExpression, Results);
8749 for (
auto *I : QualID->quals())
8751 AtArgumentExpression, Results);
8758 SemaRef.CurContext, Selectors, AtArgumentExpression,
8762 for (
auto *I : IFacePtr->quals())
8764 AtArgumentExpression, Results);
8774 for (uint32_t I = 0,
8775 N =
SemaRef.ExternalSource->GetNumExternalSelectors();
8781 SemaRef.ObjC().ReadMethodPool(Sel);
8785 for (SemaObjC::GlobalMethodPool::iterator
8786 M =
SemaRef.ObjC().MethodPool.begin(),
8787 MEnd =
SemaRef.ObjC().MethodPool.end();
8790 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
8794 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
8797 Result R(MethList->getMethod(),
8798 Results.getBasePriority(MethList->getMethod()),
8800 R.StartParameter = SelIdents.size();
8801 R.AllParametersAreInformative =
false;
8802 Results.MaybeAddResult(R,
SemaRef.CurContext);
8806 Results.ExitScope();
8813 if (AtArgumentExpression) {
8816 if (PreferredType.
isNull())
8824 Results.getCompletionContext(), Results.data(),
8831 Data.ObjCCollection =
true;
8837 Data.IgnoreDecls.push_back(*I);
8849 for (uint32_t I = 0, N =
SemaRef.ExternalSource->GetNumExternalSelectors();
8855 SemaRef.ObjC().ReadMethodPool(Sel);
8862 Results.EnterNewScope();
8863 for (SemaObjC::GlobalMethodPool::iterator
8864 M =
SemaRef.ObjC().MethodPool.begin(),
8865 MEnd =
SemaRef.ObjC().MethodPool.end();
8873 Results.getCodeCompletionTUInfo());
8875 Builder.AddTypedTextChunk(
8877 Results.AddResult(Builder.TakeString());
8881 std::string Accumulator;
8882 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
8883 if (I == SelIdents.size()) {
8884 if (!Accumulator.empty()) {
8885 Builder.AddInformativeChunk(
8886 Builder.getAllocator().CopyString(Accumulator));
8887 Accumulator.clear();
8894 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
8895 Results.AddResult(Builder.TakeString());
8897 Results.ExitScope();
8900 Results.getCompletionContext(), Results.data(),
8907 bool OnlyForwardDeclarations,
8908 ResultBuilder &Results) {
8911 for (
const auto *D : Ctx->
decls()) {
8913 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
8914 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
8915 Results.AddResult(
Result(Proto, Results.getBasePriority(Proto),
8917 CurContext,
nullptr,
false);
8928 Results.EnterNewScope();
8935 Pair.getIdentifierInfo(), Pair.getLoc()))
8936 Results.Ignore(Protocol);
8940 SemaRef.CurContext,
false, Results);
8942 Results.ExitScope();
8946 Results.getCompletionContext(), Results.data(),
8956 Results.EnterNewScope();
8960 SemaRef.CurContext,
true, Results);
8962 Results.ExitScope();
8966 Results.getCompletionContext(), Results.data(),
8973 bool OnlyForwardDeclarations,
8974 bool OnlyUnimplemented,
8975 ResultBuilder &Results) {
8978 for (
const auto *D : Ctx->
decls()) {
8980 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
8981 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
8982 (!OnlyUnimplemented || !Class->getImplementation()))
8983 Results.AddResult(
Result(Class, Results.getBasePriority(Class),
8985 CurContext,
nullptr,
false);
8993 Results.EnterNewScope();
8998 SemaRef.CurContext,
false,
false, Results);
9001 Results.ExitScope();
9004 Results.getCompletionContext(), Results.data(),
9012 Results.EnterNewScope();
9017 SemaRef.CurContext,
false,
false, Results);
9020 Results.ExitScope();
9023 Results.getCompletionContext(), Results.data(),
9032 Results.EnterNewScope();
9038 Results.Ignore(CurClass);
9043 SemaRef.CurContext,
false,
false, Results);
9046 Results.ExitScope();
9049 Results.getCompletionContext(), Results.data(),
9057 Results.EnterNewScope();
9062 SemaRef.CurContext,
false,
true, Results);
9065 Results.ExitScope();
9068 Results.getCompletionContext(), Results.data(),
9086 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
9087 for (
const auto *Cat :
Class->visible_categories())
9088 CategoryNames.insert(Cat->getIdentifier());
9092 Results.EnterNewScope();
9094 for (
const auto *D : TU->
decls())
9095 if (
const auto *Category = dyn_cast<ObjCCategoryDecl>(D))
9096 if (CategoryNames.insert(Category->getIdentifier()).second)
9097 Results.AddResult(
Result(Category, Results.getBasePriority(Category),
9099 SemaRef.CurContext,
nullptr,
false);
9100 Results.ExitScope();
9103 Results.getCompletionContext(), Results.data(),
9128 Results.EnterNewScope();
9129 bool IgnoreImplemented =
true;
9131 for (
const auto *Cat :
Class->visible_categories()) {
9132 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
9133 CategoryNames.insert(Cat->getIdentifier()).second)
9134 Results.AddResult(
Result(Cat, Results.getBasePriority(Cat),
9136 SemaRef.CurContext,
nullptr,
false);
9140 IgnoreImplemented =
false;
9142 Results.ExitScope();
9145 Results.getCompletionContext(), Results.data(),
9156 dyn_cast_or_null<ObjCContainerDecl>(
SemaRef.CurContext);
9163 for (
const auto *D : Container->
decls())
9164 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
9165 Results.Ignore(PropertyImpl->getPropertyDecl());
9169 Results.EnterNewScope();
9171 dyn_cast<ObjCImplementationDecl>(Container))
9174 AddedProperties, Results);
9178 false,
false,
SemaRef.CurContext,
9179 AddedProperties, Results);
9180 Results.ExitScope();
9183 Results.getCompletionContext(), Results.data(),
9196 dyn_cast_or_null<ObjCContainerDecl>(
SemaRef.CurContext);
9204 dyn_cast<ObjCImplementationDecl>(Container))
9205 Class = ClassImpl->getClassInterface();
9209 ->getClassInterface();
9217 Property->getType().getNonReferenceType().getUnqualifiedType();
9220 Results.setPreferredType(PropertyType);
9225 Results.EnterNewScope();
9226 bool SawSimilarlyNamedIvar =
false;
9227 std::string NameWithPrefix;
9228 NameWithPrefix +=
'_';
9229 NameWithPrefix += PropertyName->getName();
9230 std::string NameWithSuffix = PropertyName->getName().str();
9231 NameWithSuffix +=
'_';
9234 Ivar = Ivar->getNextIvar()) {
9235 Results.AddResult(
Result(Ivar, Results.getBasePriority(Ivar),
9237 SemaRef.CurContext,
nullptr,
false);
9241 if ((PropertyName == Ivar->getIdentifier() ||
9242 NameWithPrefix == Ivar->getName() ||
9243 NameWithSuffix == Ivar->getName())) {
9244 SawSimilarlyNamedIvar =
true;
9248 if (Results.size() &&
9249 Results.data()[Results.size() - 1].Kind ==
9251 Results.data()[Results.size() - 1].Declaration == Ivar)
9252 Results.data()[Results.size() - 1].Priority--;
9257 if (!SawSimilarlyNamedIvar) {
9269 Builder.AddTypedTextChunk(Allocator.
CopyString(NameWithPrefix));
9274 Results.ExitScope();
9277 Results.getCompletionContext(), Results.data(),
9284 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
9293 std::optional<bool> WantInstanceMethods,
9296 bool InOriginalClass =
true) {
9299 if (!IFace->hasDefinition())
9302 IFace = IFace->getDefinition();
9306 IFace->getReferencedProtocols();
9308 E = Protocols.
end();
9311 KnownMethods, InOriginalClass);
9314 for (
auto *Cat : IFace->visible_categories()) {
9316 KnownMethods,
false);
9320 if (IFace->getSuperClass())
9322 WantInstanceMethods, ReturnType, KnownMethods,
9329 Category->getReferencedProtocols();
9331 E = Protocols.
end();
9334 KnownMethods, InOriginalClass);
9337 if (InOriginalClass && Category->getClassInterface())
9339 WantInstanceMethods, ReturnType, KnownMethods,
9345 if (!Protocol->hasDefinition())
9347 Protocol = Protocol->getDefinition();
9348 Container = Protocol;
9352 Protocol->getReferencedProtocols();
9354 E = Protocols.
end();
9357 KnownMethods,
false);
9363 for (
auto *M : Container->
methods()) {
9364 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
9365 if (!ReturnType.
isNull() &&
9366 !Context.hasSameUnqualifiedType(ReturnType, M->getReturnType()))
9369 KnownMethods[M->getSelector()] =
9370 KnownMethodsMap::mapped_type(M, InOriginalClass);
9384 Builder.AddTextChunk(Builder.getAllocator().CopyString(Quals));
9385 Builder.AddTextChunk(
9396 if (Class->getIdentifier() && Class->getIdentifier()->getName() == Name)
9405 bool IsInstanceMethod,
9408 ResultBuilder &Results) {
9410 if (!PropName || PropName->
getLength() == 0)
9428 const char *CopiedKey;
9431 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
9433 operator const char *() {
9437 return CopiedKey = Allocator.
CopyString(Key);
9439 } Key(Allocator, PropName->
getName());
9442 std::string UpperKey = std::string(PropName->
getName());
9443 if (!UpperKey.empty())
9446 bool ReturnTypeMatchesProperty =
9449 Property->getType());
9450 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
9453 if (IsInstanceMethod &&
9455 ReturnTypeMatchesProperty && !Property->getGetterMethodDecl()) {
9460 Builder.AddTypedTextChunk(Key);
9467 if (IsInstanceMethod &&
9468 ((!ReturnType.
isNull() &&
9470 (ReturnType.
isNull() && (Property->getType()->isIntegerType() ||
9471 Property->getType()->isBooleanType())))) {
9472 std::string SelectorName = (Twine(
"is") + UpperKey).str();
9476 if (ReturnType.
isNull()) {
9478 Builder.AddTextChunk(
"BOOL");
9489 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
9490 !Property->getSetterMethodDecl()) {
9491 std::string SelectorName = (Twine(
"set") + UpperKey).str();
9493 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9494 if (ReturnType.
isNull()) {
9496 Builder.AddTextChunk(
"void");
9500 Builder.AddTypedTextChunk(
9504 Builder.AddTextChunk(Key);
9515 if (
const auto *ObjCPointer =
9540 if (IsInstanceMethod &&
9542 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
9546 if (ReturnType.
isNull()) {
9548 Builder.AddTextChunk(
"NSUInteger");
9554 Result(Builder.TakeString(),
9555 std::min(IndexedGetterPriority, UnorderedGetterPriority),
9562 if (IsInstanceMethod &&
9564 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
9566 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9567 if (ReturnType.
isNull()) {
9569 Builder.AddTextChunk(
"id");
9573 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9575 Builder.AddTextChunk(
"NSUInteger");
9577 Builder.AddTextChunk(
"index");
9578 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9584 if (IsInstanceMethod &&
9591 std::string SelectorName = (Twine(Property->getName()) +
"AtIndexes").str();
9593 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9594 if (ReturnType.
isNull()) {
9596 Builder.AddTextChunk(
"NSArray *");
9600 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9602 Builder.AddTextChunk(
"NSIndexSet *");
9604 Builder.AddTextChunk(
"indexes");
9605 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9611 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9612 std::string SelectorName = (Twine(
"get") + UpperKey).str();
9613 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName),
9614 &Context.Idents.get(
"range")};
9616 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9617 if (ReturnType.
isNull()) {
9619 Builder.AddTextChunk(
"void");
9623 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9625 Builder.AddPlaceholderChunk(
"object-type");
9626 Builder.AddTextChunk(
" **");
9628 Builder.AddTextChunk(
"buffer");
9630 Builder.AddTypedTextChunk(
"range:");
9632 Builder.AddTextChunk(
"NSRange");
9634 Builder.AddTextChunk(
"inRange");
9635 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9643 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9644 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
9645 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(
"insertObject"),
9646 &Context.Idents.get(SelectorName)};
9648 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9649 if (ReturnType.
isNull()) {
9651 Builder.AddTextChunk(
"void");
9655 Builder.AddTypedTextChunk(
"insertObject:");
9657 Builder.AddPlaceholderChunk(
"object-type");
9658 Builder.AddTextChunk(
" *");
9660 Builder.AddTextChunk(
"object");
9662 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9664 Builder.AddPlaceholderChunk(
"NSUInteger");
9666 Builder.AddTextChunk(
"index");
9667 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9673 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9674 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
9675 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName),
9676 &Context.Idents.get(
"atIndexes")};
9678 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9679 if (ReturnType.
isNull()) {
9681 Builder.AddTextChunk(
"void");
9685 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9687 Builder.AddTextChunk(
"NSArray *");
9689 Builder.AddTextChunk(
"array");
9691 Builder.AddTypedTextChunk(
"atIndexes:");
9693 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9695 Builder.AddTextChunk(
"indexes");
9696 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9702 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9703 std::string SelectorName =
9704 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
9705 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9706 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9707 if (ReturnType.
isNull()) {
9709 Builder.AddTextChunk(
"void");
9713 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9715 Builder.AddTextChunk(
"NSUInteger");
9717 Builder.AddTextChunk(
"index");
9718 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9724 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9725 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
9726 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9727 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9728 if (ReturnType.
isNull()) {
9730 Builder.AddTextChunk(
"void");
9734 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9736 Builder.AddTextChunk(
"NSIndexSet *");
9738 Builder.AddTextChunk(
"indexes");
9739 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9745 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9746 std::string SelectorName =
9747 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
9748 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName),
9749 &Context.Idents.get(
"withObject")};
9751 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9752 if (ReturnType.
isNull()) {
9754 Builder.AddTextChunk(
"void");
9758 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9760 Builder.AddPlaceholderChunk(
"NSUInteger");
9762 Builder.AddTextChunk(
"index");
9764 Builder.AddTypedTextChunk(
"withObject:");
9766 Builder.AddTextChunk(
"id");
9768 Builder.AddTextChunk(
"object");
9769 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9775 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9776 std::string SelectorName1 =
9777 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
9778 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
9779 const IdentifierInfo *SelectorIds[2] = {&Context.Idents.get(SelectorName1),
9780 &Context.Idents.get(SelectorName2)};
9782 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9783 if (ReturnType.
isNull()) {
9785 Builder.AddTextChunk(
"void");
9789 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName1 +
":"));
9791 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9793 Builder.AddTextChunk(
"indexes");
9795 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName2 +
":"));
9797 Builder.AddTextChunk(
"NSArray *");
9799 Builder.AddTextChunk(
"array");
9800 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9807 if (IsInstanceMethod &&
9813 ->
getName() ==
"NSEnumerator"))) {
9814 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
9815 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9818 if (ReturnType.
isNull()) {
9820 Builder.AddTextChunk(
"NSEnumerator *");
9824 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
9825 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9831 if (IsInstanceMethod &&
9833 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
9834 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9835 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9836 if (ReturnType.
isNull()) {
9838 Builder.AddPlaceholderChunk(
"object-type");
9839 Builder.AddTextChunk(
" *");
9843 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9845 if (ReturnType.
isNull()) {
9846 Builder.AddPlaceholderChunk(
"object-type");
9847 Builder.AddTextChunk(
" *");
9850 ReturnType, Context, Policy, Builder.getAllocator()));
9853 Builder.AddTextChunk(
"object");
9854 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9861 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9862 std::string SelectorName =
9863 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
9864 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9865 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9866 if (ReturnType.
isNull()) {
9868 Builder.AddTextChunk(
"void");
9872 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9874 Builder.AddPlaceholderChunk(
"object-type");
9875 Builder.AddTextChunk(
" *");
9877 Builder.AddTextChunk(
"object");
9878 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9884 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9885 std::string SelectorName = (Twine(
"add") + UpperKey).str();
9886 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9887 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9888 if (ReturnType.
isNull()) {
9890 Builder.AddTextChunk(
"void");
9894 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9896 Builder.AddTextChunk(
"NSSet *");
9898 Builder.AddTextChunk(
"objects");
9899 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9905 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9906 std::string SelectorName =
9907 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
9908 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9909 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9910 if (ReturnType.
isNull()) {
9912 Builder.AddTextChunk(
"void");
9916 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9918 Builder.AddPlaceholderChunk(
"object-type");
9919 Builder.AddTextChunk(
" *");
9921 Builder.AddTextChunk(
"object");
9922 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9928 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9929 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
9930 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9931 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9932 if (ReturnType.
isNull()) {
9934 Builder.AddTextChunk(
"void");
9938 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9940 Builder.AddTextChunk(
"NSSet *");
9942 Builder.AddTextChunk(
"objects");
9943 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9949 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9950 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
9951 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9952 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9953 if (ReturnType.
isNull()) {
9955 Builder.AddTextChunk(
"void");
9959 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
9961 Builder.AddTextChunk(
"NSSet *");
9963 Builder.AddTextChunk(
"objects");
9964 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9971 if (!IsInstanceMethod &&
9978 std::string SelectorName =
9979 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
9980 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
9983 if (ReturnType.
isNull()) {
9985 Builder.AddTextChunk(
"NSSet<NSString *> *");
9989 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
9996 if (!IsInstanceMethod &&
9999 std::string SelectorName =
10000 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
10001 const IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName);
10004 if (ReturnType.
isNull()) {
10006 Builder.AddTextChunk(
"BOOL");
10010 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
10018 Scope *S, std::optional<bool> IsInstanceMethod,
ParsedType ReturnTy) {
10023 Decl *IDecl =
nullptr;
10024 if (
SemaRef.CurContext->isObjCContainer()) {
10030 bool IsInImplementation =
false;
10031 if (
Decl *D = IDecl) {
10033 SearchDecl = Impl->getClassInterface();
10034 IsInImplementation =
true;
10036 dyn_cast<ObjCCategoryImplDecl>(D)) {
10037 SearchDecl = CatImpl->getCategoryDecl();
10038 IsInImplementation =
true;
10040 SearchDecl = dyn_cast<ObjCContainerDecl>(D);
10043 if (!SearchDecl && S) {
10045 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
10064 Results.EnterNewScope();
10066 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
10067 MEnd = KnownMethods.end();
10071 Results.getCodeCompletionTUInfo());
10074 if (!IsInstanceMethod) {
10075 Builder.AddTextChunk(
Method->isInstanceMethod() ?
"-" :
"+");
10081 if (ReturnType.
isNull()) {
10082 QualType ResTy =
Method->getSendResultType().stripObjCKindOfType(Context);
10083 AttributedType::stripOuterNullability(ResTy);
10092 Builder.AddTypedTextChunk(
10098 PEnd =
Method->param_end();
10099 P != PEnd; (
void)++P, ++I) {
10102 Builder.AddTypedTextChunk(
10103 Builder.getAllocator().CopyString(Sel.
getNameForSlot(I) +
":"));
10106 Builder.AddTypedTextChunk(
10107 Builder.getAllocator().CopyString(Sel.
getNameForSlot(I) +
":"));
10114 ParamType = (*P)->getType();
10116 ParamType = (*P)->getOriginalType();
10119 AttributedType::stripOuterNullability(ParamType);
10121 Context, Policy, Builder);
10124 Builder.AddTextChunk(
10125 Builder.getAllocator().CopyString(Id->getName()));
10129 if (
Method->isVariadic()) {
10130 if (
Method->param_size() > 0)
10132 Builder.AddTextChunk(
"...");
10135 if (IsInImplementation && Results.includeCodePatterns()) {
10140 if (!
Method->getReturnType()->isVoidType()) {
10142 Builder.AddTextChunk(
"return");
10144 Builder.AddPlaceholderChunk(
"expression");
10147 Builder.AddPlaceholderChunk(
"statements");
10154 auto R =
Result(Builder.TakeString(),
Method, Priority);
10155 if (!M->second.getInt())
10157 Results.AddResult(std::move(R));
10162 if (Context.getLangOpts().ObjC) {
10164 Containers.push_back(SearchDecl);
10167 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
10168 MEnd = KnownMethods.end();
10170 KnownSelectors.insert(M->first);
10175 IFace = Category->getClassInterface();
10180 if (IsInstanceMethod) {
10181 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
10182 for (
auto *P : Containers[I]->instance_properties())
10184 KnownSelectors, Results);
10188 Results.ExitScope();
10191 Results.getCompletionContext(), Results.data(),
10196 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
10200 if (
SemaRef.ExternalSource) {
10201 for (uint32_t I = 0, N =
SemaRef.ExternalSource->GetNumExternalSelectors();
10207 SemaRef.ObjC().ReadMethodPool(Sel);
10218 Results.setPreferredType(
10219 SemaRef.GetTypeFromParser(ReturnTy).getNonReferenceType());
10221 Results.EnterNewScope();
10222 for (SemaObjC::GlobalMethodPool::iterator
10223 M =
SemaRef.ObjC().MethodPool.begin(),
10224 MEnd =
SemaRef.ObjC().MethodPool.end();
10226 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
10227 : &M->second.second;
10228 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
10232 if (AtParameterName) {
10234 unsigned NumSelIdents = SelIdents.size();
10235 if (NumSelIdents &&
10236 NumSelIdents <= MethList->getMethod()->param_size()) {
10238 MethList->getMethod()->parameters()[NumSelIdents - 1];
10239 if (Param->getIdentifier()) {
10241 Results.getCodeCompletionTUInfo());
10242 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
10243 Param->getIdentifier()->getName()));
10244 Results.AddResult(Builder.TakeString());
10251 Result R(MethList->getMethod(),
10252 Results.getBasePriority(MethList->getMethod()),
10254 R.StartParameter = SelIdents.size();
10255 R.AllParametersAreInformative =
false;
10256 R.DeclaringEntity =
true;
10257 Results.MaybeAddResult(R,
SemaRef.CurContext);
10261 Results.ExitScope();
10263 if (!AtParameterName && !SelIdents.empty() &&
10264 SelIdents.front()->getName().starts_with(
"init")) {
10265 for (
const auto &M :
SemaRef.PP.macros()) {
10266 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
10268 Results.EnterNewScope();
10270 Results.getCodeCompletionTUInfo());
10271 Builder.AddTypedTextChunk(
10272 Builder.getAllocator().CopyString(M.first->getName()));
10275 Results.ExitScope();
10280 Results.getCompletionContext(), Results.data(),
10288 Results.EnterNewScope();
10292 Results.getCodeCompletionTUInfo());
10293 Builder.AddTypedTextChunk(
"if");
10295 Builder.AddPlaceholderChunk(
"condition");
10296 Results.AddResult(Builder.TakeString());
10299 Builder.AddTypedTextChunk(
"ifdef");
10301 Builder.AddPlaceholderChunk(
"macro");
10302 Results.AddResult(Builder.TakeString());
10305 Builder.AddTypedTextChunk(
"ifndef");
10307 Builder.AddPlaceholderChunk(
"macro");
10308 Results.AddResult(Builder.TakeString());
10310 if (InConditional) {
10312 Builder.AddTypedTextChunk(
"elif");
10314 Builder.AddPlaceholderChunk(
"condition");
10315 Results.AddResult(Builder.TakeString());
10318 Builder.AddTypedTextChunk(
"elifdef");
10320 Builder.AddPlaceholderChunk(
"macro");
10321 Results.AddResult(Builder.TakeString());
10324 Builder.AddTypedTextChunk(
"elifndef");
10326 Builder.AddPlaceholderChunk(
"macro");
10327 Results.AddResult(Builder.TakeString());
10330 Builder.AddTypedTextChunk(
"else");
10331 Results.AddResult(Builder.TakeString());
10334 Builder.AddTypedTextChunk(
"endif");
10335 Results.AddResult(Builder.TakeString());
10339 Builder.AddTypedTextChunk(
"include");
10341 Builder.AddTextChunk(
"\"");
10342 Builder.AddPlaceholderChunk(
"header");
10343 Builder.AddTextChunk(
"\"");
10344 Results.AddResult(Builder.TakeString());
10347 Builder.AddTypedTextChunk(
"include");
10349 Builder.AddTextChunk(
"<");
10350 Builder.AddPlaceholderChunk(
"header");
10351 Builder.AddTextChunk(
">");
10352 Results.AddResult(Builder.TakeString());
10355 Builder.AddTypedTextChunk(
"define");
10357 Builder.AddPlaceholderChunk(
"macro");
10358 Results.AddResult(Builder.TakeString());
10361 Builder.AddTypedTextChunk(
"define");
10363 Builder.AddPlaceholderChunk(
"macro");
10365 Builder.AddPlaceholderChunk(
"args");
10367 Results.AddResult(Builder.TakeString());
10370 Builder.AddTypedTextChunk(
"undef");
10372 Builder.AddPlaceholderChunk(
"macro");
10373 Results.AddResult(Builder.TakeString());
10376 Builder.AddTypedTextChunk(
"line");
10378 Builder.AddPlaceholderChunk(
"number");
10379 Results.AddResult(Builder.TakeString());
10382 Builder.AddTypedTextChunk(
"line");
10384 Builder.AddPlaceholderChunk(
"number");
10386 Builder.AddTextChunk(
"\"");
10387 Builder.AddPlaceholderChunk(
"filename");
10388 Builder.AddTextChunk(
"\"");
10389 Results.AddResult(Builder.TakeString());
10392 Builder.AddTypedTextChunk(
"error");
10394 Builder.AddPlaceholderChunk(
"message");
10395 Results.AddResult(Builder.TakeString());
10398 Builder.AddTypedTextChunk(
"pragma");
10400 Builder.AddPlaceholderChunk(
"arguments");
10401 Results.AddResult(Builder.TakeString());
10405 Builder.AddTypedTextChunk(
"import");
10407 Builder.AddTextChunk(
"\"");
10408 Builder.AddPlaceholderChunk(
"header");
10409 Builder.AddTextChunk(
"\"");
10410 Results.AddResult(Builder.TakeString());
10413 Builder.AddTypedTextChunk(
"import");
10415 Builder.AddTextChunk(
"<");
10416 Builder.AddPlaceholderChunk(
"header");
10417 Builder.AddTextChunk(
">");
10418 Results.AddResult(Builder.TakeString());
10422 Builder.AddTypedTextChunk(
"include_next");
10424 Builder.AddTextChunk(
"\"");
10425 Builder.AddPlaceholderChunk(
"header");
10426 Builder.AddTextChunk(
"\"");
10427 Results.AddResult(Builder.TakeString());
10430 Builder.AddTypedTextChunk(
"include_next");
10432 Builder.AddTextChunk(
"<");
10433 Builder.AddPlaceholderChunk(
"header");
10434 Builder.AddTextChunk(
">");
10435 Results.AddResult(Builder.TakeString());
10438 Builder.AddTypedTextChunk(
"warning");
10440 Builder.AddPlaceholderChunk(
"message");
10441 Results.AddResult(Builder.TakeString());
10445 Builder.AddTypedTextChunk(
"embed");
10447 Builder.AddTextChunk(
"\"");
10448 Builder.AddPlaceholderChunk(
"file");
10449 Builder.AddTextChunk(
"\"");
10450 Results.AddResult(Builder.TakeString());
10453 Builder.AddTypedTextChunk(
"embed");
10455 Builder.AddTextChunk(
"<");
10456 Builder.AddPlaceholderChunk(
"file");
10457 Builder.AddTextChunk(
">");
10458 Results.AddResult(Builder.TakeString());
10466 Results.ExitScope();
10469 Results.getCompletionContext(), Results.data(),
10488 Results.getCodeCompletionTUInfo());
10489 Results.EnterNewScope();
10490 for (
const auto &M :
SemaRef.PP.macros()) {
10491 Builder.AddTypedTextChunk(
10492 Builder.getAllocator().CopyString(M.first->getName()));
10496 Results.ExitScope();
10497 }
else if (IsDefinition) {
10502 Results.getCompletionContext(), Results.data(),
10515 Results.EnterNewScope();
10517 Results.getCodeCompletionTUInfo());
10518 Builder.AddTypedTextChunk(
"defined");
10521 Builder.AddPlaceholderChunk(
"macro");
10523 Results.AddResult(Builder.TakeString());
10524 Results.ExitScope();
10527 Results.getCompletionContext(), Results.data(),
10547 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
10550 llvm::sys::path::native(NativeRelDir);
10551 llvm::vfs::FileSystem &FS =
10552 SemaRef.getSourceManager().getFileManager().getVirtualFileSystem();
10557 llvm::DenseSet<StringRef> SeenResults;
10560 auto AddCompletion = [&](StringRef Filename,
bool IsDirectory) {
10563 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
10564 auto R = SeenResults.insert(TypedChunk);
10566 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
10567 *R.first = InternedTyped;
10570 Builder.AddTypedTextChunk(InternedTyped);
10578 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
10582 if (!NativeRelDir.empty()) {
10586 auto Begin = llvm::sys::path::begin(NativeRelDir);
10587 auto End = llvm::sys::path::end(NativeRelDir);
10589 llvm::sys::path::append(Dir, *Begin +
".framework",
"Headers");
10590 llvm::sys::path::append(Dir, ++Begin, End);
10592 llvm::sys::path::append(Dir, NativeRelDir);
10596 const StringRef &Dirname = llvm::sys::path::filename(Dir);
10597 const bool isQt = Dirname.starts_with(
"Qt") || Dirname ==
"ActiveQt";
10598 const bool ExtensionlessHeaders =
10599 IsSystem || isQt || Dir.ends_with(
".framework/Headers") ||
10600 IncludeDir.ends_with(
"/include") || IncludeDir.ends_with(
"\\include");
10601 std::error_code EC;
10602 unsigned Count = 0;
10603 for (
auto It = FS.dir_begin(Dir, EC);
10604 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
10605 if (++Count == 2500)
10607 StringRef Filename = llvm::sys::path::filename(It->path());
10612 llvm::sys::fs::file_type
Type = It->type();
10613 if (
Type == llvm::sys::fs::file_type::symlink_file) {
10614 if (
auto FileStatus = FS.status(It->path()))
10615 Type = FileStatus->getType();
10618 case llvm::sys::fs::file_type::directory_file:
10622 NativeRelDir.empty() && !Filename.consume_back(
".framework"))
10625 AddCompletion(Filename,
true);
10627 case llvm::sys::fs::file_type::regular_file: {
10629 const bool IsHeader = Filename.ends_with_insensitive(
".h") ||
10630 Filename.ends_with_insensitive(
".hh") ||
10631 Filename.ends_with_insensitive(
".hpp") ||
10632 Filename.ends_with_insensitive(
".hxx") ||
10633 Filename.ends_with_insensitive(
".inc") ||
10634 (ExtensionlessHeaders && !Filename.contains(
'.'));
10637 AddCompletion(Filename,
false);
10649 switch (IncludeDir.getLookupType()) {
10654 AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
10658 AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
10667 const auto &S =
SemaRef.PP.getHeaderSearchInfo();
10668 using llvm::make_range;
10671 if (
auto CurFile =
SemaRef.PP.getCurrentFileLexer()->getFileEntry())
10672 AddFilesFromIncludeDir(CurFile->getDir().getName(),
false,
10674 for (
const auto &D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
10675 AddFilesFromDirLookup(D,
false);
10677 for (
const auto &D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
10678 AddFilesFromDirLookup(D,
false);
10679 for (
const auto &D : make_range(S.system_dir_begin(), S.system_dir_end()))
10680 AddFilesFromDirLookup(D,
true);
10683 Results.getCompletionContext(), Results.data(),
10697 Results.EnterNewScope();
10698 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
10702 Twine(Platform) +
"ApplicationExtension")));
10704 Results.ExitScope();
10706 Results.getCompletionContext(), Results.data(),
10713 ResultBuilder Builder(
SemaRef, Allocator, CCTUInfo,
10716 CodeCompletionDeclConsumer Consumer(
10728 Results.insert(Results.end(), Builder.data(),
10729 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
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.
@ Type
The name was classified as a type.
@ 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...
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t
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 CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
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 AnonymousTagNameStyle