47#include "llvm/ADT/ArrayRef.h"
48#include "llvm/ADT/DenseSet.h"
49#include "llvm/ADT/SmallBitVector.h"
50#include "llvm/ADT/SmallPtrSet.h"
51#include "llvm/ADT/SmallString.h"
52#include "llvm/ADT/StringSwitch.h"
53#include "llvm/ADT/Twine.h"
54#include "llvm/ADT/iterator_range.h"
55#include "llvm/Support/Casting.h"
56#include "llvm/Support/Path.h"
57#include "llvm/Support/raw_ostream.h"
76 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
82 std::vector<Result> Results;
89 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
94 class ShadowMapEntry {
99 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector *> DeclOrVector;
103 unsigned SingleDeclIndex = 0;
106 ShadowMapEntry() =
default;
107 ShadowMapEntry(
const ShadowMapEntry &) =
delete;
108 ShadowMapEntry(ShadowMapEntry &&Move) { *
this = std::move(Move); }
109 ShadowMapEntry &operator=(
const ShadowMapEntry &) =
delete;
110 ShadowMapEntry &operator=(ShadowMapEntry &&Move) {
111 SingleDeclIndex =
Move.SingleDeclIndex;
112 DeclOrVector =
Move.DeclOrVector;
113 Move.DeclOrVector =
nullptr;
118 if (DeclOrVector.isNull()) {
121 SingleDeclIndex = Index;
125 if (
const NamedDecl *PrevND = dyn_cast<const NamedDecl *>(DeclOrVector)) {
128 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
129 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
134 cast<DeclIndexPairVector *>(DeclOrVector)
135 ->push_back(DeclIndexPair(ND, Index));
139 if (DeclIndexPairVector *Vec =
140 DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
148 iterator begin()
const;
149 iterator end()
const;
155 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
172 bool AllowNestedNameSpecifiers;
183 std::list<ShadowMap> ShadowMaps;
197 bool HasObjectTypeQualifiers;
209 void AdjustResultPriorityForDecl(Result &R);
211 void MaybeAddConstructorResults(Result R);
217 LookupFilter Filter =
nullptr)
218 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
220 HasObjectTypeQualifiers(
false), CompletionContext(CompletionContext),
221 ObjCImplementation(nullptr) {
224 switch (CompletionContext.
getKind()) {
232 if (Method->isInstanceMethod())
234 ObjCImplementation =
Interface->getImplementation();
247 bool includeCodePatterns()
const {
253 void setFilter(LookupFilter Filter) { this->Filter =
Filter; }
255 Result *data() {
return Results.empty() ? nullptr : &Results.front(); }
256 unsigned size()
const {
return Results.size(); }
257 bool empty()
const {
return Results.empty(); }
272 ObjectTypeQualifiers = Quals;
274 HasObjectTypeQualifiers =
true;
282 void setPreferredSelector(
Selector Sel) { PreferredSelector = Sel; }
287 return CompletionContext;
291 void allowNestedNameSpecifiers(
bool Allow =
true) {
292 AllowNestedNameSpecifiers = Allow;
297 Sema &getSema()
const {
return SemaRef; }
311 bool isInterestingDecl(
const NamedDecl *ND,
312 bool &AsNestedNameSpecifier)
const;
337 bool CheckHiddenResult(Result &R,
DeclContext *CurContext,
347 void MaybeAddResult(Result R,
DeclContext *CurContext =
nullptr);
364 bool InBaseClass,
QualType BaseExprType);
367 void AddResult(Result R);
370 void EnterNewScope();
389 bool IsOrdinaryName(
const NamedDecl *ND)
const;
390 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
391 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
392 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
393 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
395 bool IsClassOrStruct(
const NamedDecl *ND)
const;
397 bool IsNamespace(
const NamedDecl *ND)
const;
398 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
400 bool IsMember(
const NamedDecl *ND)
const;
401 bool IsObjCIvar(
const NamedDecl *ND)
const;
402 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
403 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
404 bool IsObjCCollection(
const NamedDecl *ND)
const;
405 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
415 ComputeType =
nullptr;
416 Type = BSI->ReturnType;
420 ComputeType =
nullptr;
423 }
else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(S.
CurContext)) {
424 ComputeType =
nullptr;
425 Type = Method->getReturnType();
433 auto *VD = llvm::dyn_cast_or_null<ValueDecl>(
D);
434 ComputeType =
nullptr;
446 ComputeType =
nullptr;
455 this->ComputeType = ComputeType;
465 if (ExpectedLoc == LParLoc)
476 if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
479 if (Op == tok::minus)
492 case tok::minusequal:
494 case tok::percentequal:
496 case tok::slashequal:
502 case tok::equalequal:
503 case tok::exclaimequal:
507 case tok::greaterequal:
511 case tok::greatergreater:
512 case tok::greatergreaterequal:
514 case tok::lesslessequal:
527 case tok::caretequal:
535 case tok::periodstar:
563 case tok::minusminus:
573 assert(
false &&
"unhandled unary op");
582 ComputeType =
nullptr;
589 if (!Enabled || !
Base)
592 if (ExpectedLoc !=
Base->getBeginLoc())
603 ComputeType =
nullptr;
612 ComputeType =
nullptr;
621 ComputeType =
nullptr;
629 ComputeType =
nullptr;
635 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
636 unsigned SingleDeclIndex;
656 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) {}
659 : DeclOrIterator(Iterator), SingleDeclIndex(0) {}
662 if (isa<const NamedDecl *>(DeclOrIterator)) {
668 const DeclIndexPair *I = cast<const DeclIndexPair *>(DeclOrIterator);
684 return *cast<const DeclIndexPair *>(DeclOrIterator);
690 return X.DeclOrIterator.getOpaqueValue() ==
691 Y.DeclOrIterator.getOpaqueValue() &&
692 X.SingleDeclIndex == Y.SingleDeclIndex;
701ResultBuilder::ShadowMapEntry::begin()
const {
702 if (DeclOrVector.isNull())
705 if (
const NamedDecl *ND = dyn_cast<const NamedDecl *>(DeclOrVector))
706 return iterator(ND, SingleDeclIndex);
708 return iterator(cast<DeclIndexPairVector *>(DeclOrVector)->begin());
712ResultBuilder::ShadowMapEntry::end()
const {
713 if (isa<const NamedDecl *>(DeclOrVector) || DeclOrVector.isNull())
716 return iterator(cast<DeclIndexPairVector *>(DeclOrVector)->end());
737 for (
const DeclContext *CommonAncestor = TargetContext;
738 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
739 CommonAncestor = CommonAncestor->getLookupParent()) {
740 if (CommonAncestor->isTransparentContext() ||
741 CommonAncestor->isFunctionOrMethod())
744 TargetParents.push_back(CommonAncestor);
748 while (!TargetParents.empty()) {
751 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(
Parent)) {
752 if (!Namespace->getIdentifier())
756 }
else if (
const auto *TD = dyn_cast<TagDecl>(
Parent))
787bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
788 bool &AsNestedNameSpecifier)
const {
789 AsNestedNameSpecifier =
false;
804 if (isa<ClassTemplateSpecializationDecl>(ND) ||
805 isa<ClassTemplatePartialSpecializationDecl>(ND))
809 if (isa<UsingDecl>(ND))
815 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
816 (isa<NamespaceDecl>(ND) && Filter != &ResultBuilder::IsNamespace &&
817 Filter != &ResultBuilder::IsNamespaceOrAlias && Filter !=
nullptr))
818 AsNestedNameSpecifier =
true;
821 if (Filter && !(this->*Filter)(Named)) {
823 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
824 IsNestedNameSpecifier(ND) &&
825 (Filter != &ResultBuilder::IsMember ||
826 (isa<CXXRecordDecl>(ND) &&
827 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
828 AsNestedNameSpecifier =
true;
858 R.QualifierIsInformative =
false;
862 R.Declaration->getDeclContext());
871 switch (cast<BuiltinType>(
T)->
getKind()) {
872 case BuiltinType::Void:
875 case BuiltinType::NullPtr:
878 case BuiltinType::Overload:
879 case BuiltinType::Dependent:
882 case BuiltinType::ObjCId:
883 case BuiltinType::ObjCClass:
884 case BuiltinType::ObjCSel:
897 case Type::BlockPointer:
900 case Type::LValueReference:
901 case Type::RValueReference:
904 case Type::ConstantArray:
905 case Type::IncompleteArray:
906 case Type::VariableArray:
907 case Type::DependentSizedArray:
910 case Type::DependentSizedExtVector:
912 case Type::ExtVector:
915 case Type::FunctionProto:
916 case Type::FunctionNoProto:
925 case Type::ObjCObject:
926 case Type::ObjCInterface:
927 case Type::ObjCObjectPointer:
940 if (
const auto *
Type = dyn_cast<TypeDecl>(ND))
941 return C.getTypeDeclType(
Type);
942 if (
const auto *Iface = dyn_cast<ObjCInterfaceDecl>(ND))
943 return C.getObjCInterfaceType(Iface);
948 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND))
949 T = Method->getSendResultType();
950 else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND))
951 T =
C.getTypeDeclType(cast<EnumDecl>(Enumerator->getDeclContext()));
952 else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND))
954 else if (
const auto *
Value = dyn_cast<ValueDecl>(ND))
970 if (
Pointer->getPointeeType()->isFunctionType()) {
979 T =
Block->getPointeeType();
994unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
1002 if (
const auto *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND))
1003 if (ImplicitParam->getIdentifier() &&
1004 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
1011 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC)) {
1013 if (isa<CXXDestructorDecl>(ND))
1025 if (isa<EnumConstantDecl>(ND))
1031 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
1033 CompletionContext.
getKind() ==
1035 CompletionContext.
getKind() ==
1042void ResultBuilder::AdjustResultPriorityForDecl(
Result &R) {
1045 if (!PreferredSelector.
isNull())
1046 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
1047 if (PreferredSelector == Method->getSelector())
1052 if (!PreferredType.
isNull()) {
1062 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
1074 return Record->lookup(ConstructorName);
1077void ResultBuilder::MaybeAddConstructorResults(
Result R) {
1078 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
1085 Record = ClassTemplate->getTemplatedDecl();
1086 else if ((
Record = dyn_cast<CXXRecordDecl>(
D))) {
1088 if (isa<ClassTemplateSpecializationDecl>(
Record))
1100 R.Declaration = Ctor;
1102 Results.push_back(R);
1107 if (
const auto *Tmpl = dyn_cast<FunctionTemplateDecl>(ND))
1108 ND = Tmpl->getTemplatedDecl();
1109 return isa<CXXConstructorDecl>(ND);
1113 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
1115 if (R.Kind != Result::RK_Declaration) {
1117 Results.push_back(R);
1122 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1124 getBasePriority(
Using->getTargetDecl()),
1128 std::move(R.FixIts));
1130 MaybeAddResult(
Result, CurContext);
1137 bool AsNestedNameSpecifier =
false;
1138 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1145 ShadowMap &
SMap = ShadowMaps.back();
1146 ShadowMapEntry::iterator I, IEnd;
1147 ShadowMap::iterator NamePos =
SMap.find(R.Declaration->getDeclName());
1148 if (NamePos !=
SMap.end()) {
1149 I = NamePos->second.begin();
1150 IEnd = NamePos->second.end();
1153 for (; I != IEnd; ++I) {
1155 unsigned Index = I->second;
1158 Results[Index].Declaration = R.Declaration;
1168 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
1170 for (
SM = ShadowMaps.begin();
SM != SMEnd; ++
SM) {
1171 ShadowMapEntry::iterator I, IEnd;
1172 ShadowMap::iterator NamePos =
SM->find(R.Declaration->getDeclName());
1173 if (NamePos !=
SM->end()) {
1174 I = NamePos->second.begin();
1175 IEnd = NamePos->second.end();
1177 for (; I != IEnd; ++I) {
1179 if (I->first->hasTagIdentifierNamespace() &&
1187 I->first->getIdentifierNamespace() != IDNS)
1191 if (CheckHiddenResult(R, CurContext, I->first))
1199 if (!AllDeclsFound.insert(CanonDecl).second)
1204 if (AsNestedNameSpecifier) {
1205 R.StartsNestedNameSpecifier =
true;
1208 AdjustResultPriorityForDecl(R);
1211 if (R.QualifierIsInformative && !R.Qualifier &&
1212 !R.StartsNestedNameSpecifier) {
1213 const DeclContext *Ctx = R.Declaration->getDeclContext();
1214 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1217 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1219 SemaRef.
Context,
nullptr,
false,
1222 R.QualifierIsInformative =
false;
1227 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
1228 Results.push_back(R);
1230 if (!AsNestedNameSpecifier)
1231 MaybeAddConstructorResults(R);
1251 return OverloadCompare::BothViable;
1256 return OverloadCompare::BothViable;
1258 if (Candidate.
parameters()[I]->getType().getCanonicalType() !=
1259 Incumbent.
parameters()[I]->getType().getCanonicalType())
1260 return OverloadCompare::BothViable;
1263 return OverloadCompare::BothViable;
1268 if (CandidateRef != IncumbentRef) {
1275 return CandidateRef ==
RQ_RValue ? OverloadCompare::Dominates
1276 : OverloadCompare::Dominated;
1284 if (CandidateSuperset == IncumbentSuperset)
1285 return OverloadCompare::BothViable;
1286 return IncumbentSuperset ? OverloadCompare::Dominates
1287 : OverloadCompare::Dominated;
1290bool ResultBuilder::canCxxMethodBeCalled(
const CXXMethodDecl *Method,
1296 const auto *CurrentClassScope = [&]() ->
const CXXRecordDecl * {
1297 for (
DeclContext *Ctx = CurContext; Ctx; Ctx = Ctx->getParent()) {
1298 const auto *CtxMethod = llvm::dyn_cast<CXXMethodDecl>(Ctx);
1299 if (CtxMethod && !CtxMethod->getParent()->isLambda()) {
1300 return CtxMethod->getParent();
1307 bool FunctionCanBeCall =
1308 CurrentClassScope &&
1309 (CurrentClassScope == Method->
getParent() ||
1313 if (FunctionCanBeCall)
1318 BaseExprType.
isNull() ?
nullptr
1322 MaybeDerived == MaybeBase || MaybeDerived->
isDerivedFrom(MaybeBase);
1325 return FunctionCanBeCall;
1328bool ResultBuilder::canFunctionBeCalled(
const NamedDecl *ND,
1339 if (
const auto *FuncTmpl = dyn_cast<FunctionTemplateDecl>(ND)) {
1340 ND = FuncTmpl->getTemplatedDecl();
1342 const auto *Method = dyn_cast<CXXMethodDecl>(ND);
1343 if (Method && !Method->
isStatic()) {
1344 return canCxxMethodBeCalled(Method, BaseExprType);
1351 NamedDecl *Hiding,
bool InBaseClass =
false,
1353 if (R.Kind != Result::RK_Declaration) {
1355 Results.push_back(R);
1360 if (
const auto *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
1362 getBasePriority(
Using->getTargetDecl()),
1366 std::move(R.FixIts));
1368 AddResult(
Result, CurContext, Hiding,
false,
1373 bool AsNestedNameSpecifier =
false;
1374 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
1381 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
1385 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
1390 if (AsNestedNameSpecifier) {
1391 R.StartsNestedNameSpecifier =
true;
1393 }
else if (Filter == &ResultBuilder::IsMember && !R.Qualifier &&
1396 R.Declaration->getDeclContext()->getRedeclContext()))
1397 R.QualifierIsInformative =
true;
1400 if (R.QualifierIsInformative && !R.Qualifier &&
1401 !R.StartsNestedNameSpecifier) {
1402 const DeclContext *Ctx = R.Declaration->getDeclContext();
1403 if (
const auto *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1406 else if (
const auto *Tag = dyn_cast<TagDecl>(Ctx))
1408 SemaRef.
Context,
nullptr,
false,
1411 R.QualifierIsInformative =
false;
1418 AdjustResultPriorityForDecl(R);
1420 if (HasObjectTypeQualifiers)
1421 if (
const auto *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1424 if (ObjectTypeQualifiers == MethodQuals)
1426 else if (ObjectTypeQualifiers - MethodQuals) {
1448 auto &OverloadSet = OverloadMap[std::make_pair(
1450 for (
const DeclIndexPair Entry : OverloadSet) {
1451 Result &Incumbent = Results[Entry.second];
1453 *cast<CXXMethodDecl>(Incumbent.Declaration),
1454 ObjectTypeQualifiers, ObjectKind,
1456 case OverloadCompare::Dominates:
1460 Incumbent = std::move(R);
1462 case OverloadCompare::Dominated:
1465 case OverloadCompare::BothViable:
1469 OverloadSet.Add(Method, Results.size());
1472 R.FunctionCanBeCall = canFunctionBeCalled(R.getDeclaration(), BaseExprType);
1475 Results.push_back(R);
1477 if (!AsNestedNameSpecifier)
1478 MaybeAddConstructorResults(R);
1481void ResultBuilder::AddResult(
Result R) {
1482 assert(R.Kind != Result::RK_Declaration &&
1483 "Declaration results need more context");
1484 Results.push_back(R);
1488void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1491void ResultBuilder::ExitScope() {
1492 ShadowMaps.pop_back();
1497bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1506 if (isa<ObjCIvarDecl>(ND))
1515bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1517 if (isa<TypeDecl>(ND))
1522 if (
const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1523 if (!
ID->getDefinition())
1531 if (isa<ObjCIvarDecl>(ND))
1538bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1539 if (!IsOrdinaryNonTypeName(ND))
1543 if (VD->getType()->isIntegralOrEnumerationType())
1551bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1559 !isa<FunctionTemplateDecl>(ND) && !isa<ObjCPropertyDecl>(ND);
1564bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1566 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1567 ND = ClassTemplate->getTemplatedDecl();
1573bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1574 return isa<EnumDecl>(ND);
1578bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1580 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1581 ND = ClassTemplate->getTemplatedDecl();
1584 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1593bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1595 if (
const auto *ClassTemplate = dyn_cast<ClassTemplateDecl>(ND))
1596 ND = ClassTemplate->getTemplatedDecl();
1598 if (
const auto *RD = dyn_cast<RecordDecl>(ND))
1605bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1606 return isa<NamespaceDecl>(ND);
1611bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1616bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1618 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1624bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1626 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1627 isa<ObjCPropertyDecl>(ND);
1631 T =
C.getCanonicalType(
T);
1633 case Type::ObjCObject:
1634 case Type::ObjCInterface:
1635 case Type::ObjCObjectPointer:
1639 switch (cast<BuiltinType>(
T)->
getKind()) {
1640 case BuiltinType::ObjCId:
1641 case BuiltinType::ObjCClass:
1642 case BuiltinType::ObjCSel:
1654 if (!
C.getLangOpts().CPlusPlus)
1663bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1672bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
1674 if (IsObjCMessageReceiver(ND))
1677 const auto *Var = dyn_cast<VarDecl>(ND);
1681 return Var->hasLocalStorage() && !Var->hasAttr<BlocksAttr>();
1684bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1685 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1686 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1699bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1705bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1706 return isa<ObjCIvarDecl>(ND);
1714 ResultBuilder &Results;
1720 std::vector<FixItHint> FixIts;
1723 CodeCompletionDeclConsumer(
1724 ResultBuilder &Results,
DeclContext *InitialLookupCtx,
1726 std::vector<FixItHint> FixIts = std::vector<FixItHint>())
1727 : Results(Results), InitialLookupCtx(InitialLookupCtx),
1728 FixIts(
std::move(FixIts)) {
1729 NamingClass = llvm::dyn_cast<CXXRecordDecl>(InitialLookupCtx);
1732 auto ThisType = Results.getSema().getCurrentThisType();
1733 if (!ThisType.isNull()) {
1734 assert(ThisType->isPointerType());
1740 this->BaseType = BaseType;
1744 bool InBaseClass)
override {
1747 Results.AddResult(Result, InitialLookupCtx, Hiding, InBaseClass, BaseType);
1751 Results.addVisitedContext(Ctx);
1760 auto *NamingClass = this->NamingClass;
1761 QualType BaseType = this->BaseType;
1762 if (
auto *Cls = llvm::dyn_cast_or_null<CXXRecordDecl>(Ctx)) {
1777 NamingClass =
nullptr;
1780 return Results.getSema().IsSimplyAccessible(ND, NamingClass, BaseType);
1787 ResultBuilder &Results) {
1814 Results.getCodeCompletionTUInfo());
1815 if (LangOpts.CPlusPlus) {
1823 Builder.AddTypedTextChunk(
"typename");
1825 Builder.AddPlaceholderChunk(
"name");
1826 Results.AddResult(
Result(Builder.TakeString()));
1828 if (LangOpts.CPlusPlus11) {
1833 Builder.AddTypedTextChunk(
"decltype");
1835 Builder.AddPlaceholderChunk(
"expression");
1837 Results.AddResult(
Result(Builder.TakeString()));
1840 if (LangOpts.Char8 || LangOpts.CPlusPlus20)
1846 if (LangOpts.GNUKeywords) {
1852 Builder.AddTypedTextChunk(
"typeof");
1854 Builder.AddPlaceholderChunk(
"expression");
1855 Results.AddResult(
Result(Builder.TakeString()));
1857 Builder.AddTypedTextChunk(
"typeof");
1859 Builder.AddPlaceholderChunk(
"type");
1861 Results.AddResult(
Result(Builder.TakeString()));
1872 const LangOptions &LangOpts, ResultBuilder &Results) {
1877 Results.AddResult(
Result(
"extern"));
1878 Results.AddResult(
Result(
"static"));
1880 if (LangOpts.CPlusPlus11) {
1885 Builder.AddTypedTextChunk(
"alignas");
1887 Builder.AddPlaceholderChunk(
"expression");
1889 Results.AddResult(
Result(Builder.TakeString()));
1891 Results.AddResult(
Result(
"constexpr"));
1892 Results.AddResult(
Result(
"thread_local"));
1895 if (LangOpts.CPlusPlus20)
1896 Results.AddResult(
Result(
"constinit"));
1901 const LangOptions &LangOpts, ResultBuilder &Results) {
1906 if (LangOpts.CPlusPlus) {
1907 Results.AddResult(
Result(
"explicit"));
1908 Results.AddResult(
Result(
"friend"));
1909 Results.AddResult(
Result(
"mutable"));
1910 Results.AddResult(
Result(
"virtual"));
1918 if (LangOpts.CPlusPlus || LangOpts.C99)
1919 Results.AddResult(
Result(
"inline"));
1921 if (LangOpts.CPlusPlus20)
1922 Results.AddResult(
Result(
"consteval"));
1942 ResultBuilder &Results,
bool NeedAt);
1944 ResultBuilder &Results,
bool NeedAt);
1946 ResultBuilder &Results,
bool NeedAt);
1951 Results.getCodeCompletionTUInfo());
1952 Builder.AddTypedTextChunk(
"typedef");
1954 Builder.AddPlaceholderChunk(
"type");
1956 Builder.AddPlaceholderChunk(
"name");
1963 ResultBuilder &Results) {
1964 Builder.AddTypedTextChunk(
"using");
1966 Builder.AddPlaceholderChunk(
"name");
1968 Builder.AddPlaceholderChunk(
"type");
1991 return LangOpts.CPlusPlus;
1998 return LangOpts.CPlusPlus || LangOpts.ObjC || LangOpts.C99;
2001 llvm_unreachable(
"Invalid ParserCompletionContext!");
2028 if (!
T.getLocalQualifiers()) {
2031 return BT->getNameAsCString(Policy);
2034 if (
const TagType *TagT = dyn_cast<TagType>(
T))
2035 if (
TagDecl *Tag = TagT->getDecl())
2036 if (!Tag->hasNameForLinkage()) {
2037 switch (Tag->getTagKind()) {
2039 return "struct <anonymous>";
2041 return "__interface <anonymous>";
2043 return "class <anonymous>";
2045 return "union <anonymous>";
2047 return "enum <anonymous>";
2054 T.getAsStringInternal(
Result, Policy);
2055 return Allocator.CopyString(
Result);
2067 Builder.AddResultTypeChunk(
2069 Builder.AddTypedTextChunk(
"this");
2074 ResultBuilder &Results,
2076 if (!LangOpts.CPlusPlus11)
2079 Builder.AddTypedTextChunk(
"static_assert");
2081 Builder.AddPlaceholderChunk(
"expression");
2083 Builder.AddPlaceholderChunk(
"message");
2092 Sema &S = Results.getSema();
2093 const auto *CR = llvm::dyn_cast<CXXRecordDecl>(S.
CurContext);
2099 llvm::StringMap<std::vector<FunctionDecl *>> Overrides;
2100 for (
auto *Method : CR->methods()) {
2103 Overrides[Method->
getName()].push_back(Method);
2106 for (
const auto &
Base : CR->bases()) {
2107 const auto *BR =
Base.getType().getTypePtr()->getAsCXXRecordDecl();
2110 for (
auto *Method : BR->methods()) {
2113 const auto it = Overrides.find(Method->
getName());
2114 bool IsOverriden =
false;
2115 if (it != Overrides.end()) {
2116 for (
auto *MD : it->second) {
2134 false, CCContext, Policy);
2144 Scope *S,
Sema &SemaRef, ResultBuilder &Results) {
2152 if (Results.includeCodePatterns()) {
2154 Builder.AddTypedTextChunk(
"namespace");
2156 Builder.AddPlaceholderChunk(
"identifier");
2160 Builder.AddPlaceholderChunk(
"declarations");
2163 Results.AddResult(
Result(Builder.TakeString()));
2167 Builder.AddTypedTextChunk(
"namespace");
2169 Builder.AddPlaceholderChunk(
"name");
2171 Builder.AddPlaceholderChunk(
"namespace");
2173 Results.AddResult(
Result(Builder.TakeString()));
2176 Builder.AddTypedTextChunk(
"using namespace");
2178 Builder.AddPlaceholderChunk(
"identifier");
2180 Results.AddResult(
Result(Builder.TakeString()));
2183 Builder.AddTypedTextChunk(
"asm");
2185 Builder.AddPlaceholderChunk(
"string-literal");
2187 Results.AddResult(
Result(Builder.TakeString()));
2189 if (Results.includeCodePatterns()) {
2191 Builder.AddTypedTextChunk(
"template");
2193 Builder.AddPlaceholderChunk(
"declaration");
2194 Results.AddResult(
Result(Builder.TakeString()));
2205 if (!CurrentModule) {
2207 Builder.AddTypedTextChunk(
"module");
2210 Results.AddResult(
Result(Builder.TakeString()));
2215 if (!CurrentModule ||
2220 Builder.AddTypedTextChunk(
"module");
2222 Builder.AddPlaceholderChunk(
"name");
2225 Results.AddResult(
Result(Builder.TakeString()));
2230 if (!CurrentModule ||
2234 Builder.AddTypedTextChunk(
"import");
2236 Builder.AddPlaceholderChunk(
"name");
2239 Results.AddResult(
Result(Builder.TakeString()));
2242 if (CurrentModule &&
2246 Builder.AddTypedTextChunk(
"module");
2249 Builder.AddTypedTextChunk(
"private");
2252 Results.AddResult(
Result(Builder.TakeString()));
2257 if (!CurrentModule ||
2272 Builder.AddTypedTextChunk(
"using");
2274 Builder.AddPlaceholderChunk(
"qualifier");
2275 Builder.AddTextChunk(
"::");
2276 Builder.AddPlaceholderChunk(
"name");
2278 Results.AddResult(
Result(Builder.TakeString()));
2285 Builder.AddTypedTextChunk(
"using typename");
2287 Builder.AddPlaceholderChunk(
"qualifier");
2288 Builder.AddTextChunk(
"::");
2289 Builder.AddPlaceholderChunk(
"name");
2291 Results.AddResult(
Result(Builder.TakeString()));
2299 bool IsNotInheritanceScope = !S->isClassInheritanceScope();
2301 Builder.AddTypedTextChunk(
"public");
2302 if (IsNotInheritanceScope && Results.includeCodePatterns())
2304 Results.AddResult(
Result(Builder.TakeString()));
2307 Builder.AddTypedTextChunk(
"protected");
2308 if (IsNotInheritanceScope && Results.includeCodePatterns())
2310 Results.AddResult(
Result(Builder.TakeString()));
2313 Builder.AddTypedTextChunk(
"private");
2314 if (IsNotInheritanceScope && Results.includeCodePatterns())
2316 Results.AddResult(
Result(Builder.TakeString()));
2334 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
2336 Builder.AddTypedTextChunk(
"template");
2338 Builder.AddPlaceholderChunk(
"parameters");
2340 Results.AddResult(
Result(Builder.TakeString()));
2378 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
2380 Builder.AddTypedTextChunk(
"try");
2384 Builder.AddPlaceholderChunk(
"statements");
2388 Builder.AddTextChunk(
"catch");
2391 Builder.AddPlaceholderChunk(
"declaration");
2396 Builder.AddPlaceholderChunk(
"statements");
2399 Results.AddResult(
Result(Builder.TakeString()));
2404 if (Results.includeCodePatterns()) {
2406 Builder.AddTypedTextChunk(
"if");
2410 Builder.AddPlaceholderChunk(
"condition");
2412 Builder.AddPlaceholderChunk(
"expression");
2417 Builder.AddPlaceholderChunk(
"statements");
2420 Results.AddResult(
Result(Builder.TakeString()));
2423 Builder.AddTypedTextChunk(
"switch");
2427 Builder.AddPlaceholderChunk(
"condition");
2429 Builder.AddPlaceholderChunk(
"expression");
2434 Builder.AddPlaceholderChunk(
"cases");
2437 Results.AddResult(
Result(Builder.TakeString()));
2444 Builder.AddTypedTextChunk(
"case");
2446 Builder.AddPlaceholderChunk(
"expression");
2448 Results.AddResult(
Result(Builder.TakeString()));
2451 Builder.AddTypedTextChunk(
"default");
2453 Results.AddResult(
Result(Builder.TakeString()));
2456 if (Results.includeCodePatterns()) {
2458 Builder.AddTypedTextChunk(
"while");
2462 Builder.AddPlaceholderChunk(
"condition");
2464 Builder.AddPlaceholderChunk(
"expression");
2469 Builder.AddPlaceholderChunk(
"statements");
2472 Results.AddResult(
Result(Builder.TakeString()));
2475 Builder.AddTypedTextChunk(
"do");
2479 Builder.AddPlaceholderChunk(
"statements");
2482 Builder.AddTextChunk(
"while");
2485 Builder.AddPlaceholderChunk(
"expression");
2487 Results.AddResult(
Result(Builder.TakeString()));
2490 Builder.AddTypedTextChunk(
"for");
2494 Builder.AddPlaceholderChunk(
"init-statement");
2496 Builder.AddPlaceholderChunk(
"init-expression");
2499 Builder.AddPlaceholderChunk(
"condition");
2502 Builder.AddPlaceholderChunk(
"inc-expression");
2507 Builder.AddPlaceholderChunk(
"statements");
2510 Results.AddResult(
Result(Builder.TakeString()));
2514 Builder.AddTypedTextChunk(
"for");
2517 Builder.AddPlaceholderChunk(
"range-declaration");
2520 Builder.AddTextChunk(
"in");
2524 Builder.AddPlaceholderChunk(
"range-expression");
2529 Builder.AddPlaceholderChunk(
"statements");
2532 Results.AddResult(
Result(Builder.TakeString()));
2536 if (S->getContinueParent()) {
2538 Builder.AddTypedTextChunk(
"continue");
2540 Results.AddResult(
Result(Builder.TakeString()));
2543 if (S->getBreakParent()) {
2545 Builder.AddTypedTextChunk(
"break");
2547 Results.AddResult(
Result(Builder.TakeString()));
2553 ReturnType =
Function->getReturnType();
2554 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
2560 Builder.AddTypedTextChunk(
"return");
2562 Results.AddResult(
Result(Builder.TakeString()));
2564 assert(!ReturnType.
isNull());
2566 Builder.AddTypedTextChunk(
"return");
2568 Builder.AddPlaceholderChunk(
"expression");
2570 Results.AddResult(
Result(Builder.TakeString()));
2573 Builder.AddTypedTextChunk(
"co_return");
2575 Builder.AddPlaceholderChunk(
"expression");
2577 Results.AddResult(
Result(Builder.TakeString()));
2581 Builder.AddTypedTextChunk(
"return true");
2583 Results.AddResult(
Result(Builder.TakeString()));
2585 Builder.AddTypedTextChunk(
"return false");
2587 Results.AddResult(
Result(Builder.TakeString()));
2592 Builder.AddTypedTextChunk(
"return nullptr");
2594 Results.AddResult(
Result(Builder.TakeString()));
2599 Builder.AddTypedTextChunk(
"goto");
2601 Builder.AddPlaceholderChunk(
"label");
2603 Results.AddResult(
Result(Builder.TakeString()));
2606 Builder.AddTypedTextChunk(
"using namespace");
2608 Builder.AddPlaceholderChunk(
"identifier");
2610 Results.AddResult(
Result(Builder.TakeString()));
2627 Builder.AddTypedTextChunk(
"__bridge");
2629 Builder.AddPlaceholderChunk(
"type");
2631 Builder.AddPlaceholderChunk(
"expression");
2632 Results.AddResult(
Result(Builder.TakeString()));
2635 Builder.AddTypedTextChunk(
"__bridge_transfer");
2637 Builder.AddPlaceholderChunk(
"Objective-C type");
2639 Builder.AddPlaceholderChunk(
"expression");
2640 Results.AddResult(
Result(Builder.TakeString()));
2643 Builder.AddTypedTextChunk(
"__bridge_retained");
2645 Builder.AddPlaceholderChunk(
"CF type");
2647 Builder.AddPlaceholderChunk(
"expression");
2648 Results.AddResult(
Result(Builder.TakeString()));
2659 Builder.AddResultTypeChunk(
"bool");
2660 Builder.AddTypedTextChunk(
"true");
2661 Results.AddResult(
Result(Builder.TakeString()));
2664 Builder.AddResultTypeChunk(
"bool");
2665 Builder.AddTypedTextChunk(
"false");
2666 Results.AddResult(
Result(Builder.TakeString()));
2670 Builder.AddTypedTextChunk(
"dynamic_cast");
2672 Builder.AddPlaceholderChunk(
"type");
2675 Builder.AddPlaceholderChunk(
"expression");
2677 Results.AddResult(
Result(Builder.TakeString()));
2681 Builder.AddTypedTextChunk(
"static_cast");
2683 Builder.AddPlaceholderChunk(
"type");
2686 Builder.AddPlaceholderChunk(
"expression");
2688 Results.AddResult(
Result(Builder.TakeString()));
2691 Builder.AddTypedTextChunk(
"reinterpret_cast");
2693 Builder.AddPlaceholderChunk(
"type");
2696 Builder.AddPlaceholderChunk(
"expression");
2698 Results.AddResult(
Result(Builder.TakeString()));
2701 Builder.AddTypedTextChunk(
"const_cast");
2703 Builder.AddPlaceholderChunk(
"type");
2706 Builder.AddPlaceholderChunk(
"expression");
2708 Results.AddResult(
Result(Builder.TakeString()));
2712 Builder.AddResultTypeChunk(
"std::type_info");
2713 Builder.AddTypedTextChunk(
"typeid");
2715 Builder.AddPlaceholderChunk(
"expression-or-type");
2717 Results.AddResult(
Result(Builder.TakeString()));
2721 Builder.AddTypedTextChunk(
"new");
2723 Builder.AddPlaceholderChunk(
"type");
2725 Builder.AddPlaceholderChunk(
"expressions");
2727 Results.AddResult(
Result(Builder.TakeString()));
2730 Builder.AddTypedTextChunk(
"new");
2732 Builder.AddPlaceholderChunk(
"type");
2734 Builder.AddPlaceholderChunk(
"size");
2737 Builder.AddPlaceholderChunk(
"expressions");
2739 Results.AddResult(
Result(Builder.TakeString()));
2742 Builder.AddResultTypeChunk(
"void");
2743 Builder.AddTypedTextChunk(
"delete");
2745 Builder.AddPlaceholderChunk(
"expression");
2746 Results.AddResult(
Result(Builder.TakeString()));
2749 Builder.AddResultTypeChunk(
"void");
2750 Builder.AddTypedTextChunk(
"delete");
2755 Builder.AddPlaceholderChunk(
"expression");
2756 Results.AddResult(
Result(Builder.TakeString()));
2760 Builder.AddResultTypeChunk(
"void");
2761 Builder.AddTypedTextChunk(
"throw");
2763 Builder.AddPlaceholderChunk(
"expression");
2764 Results.AddResult(
Result(Builder.TakeString()));
2771 Builder.AddResultTypeChunk(
"std::nullptr_t");
2772 Builder.AddTypedTextChunk(
"nullptr");
2773 Results.AddResult(
Result(Builder.TakeString()));
2776 Builder.AddResultTypeChunk(
"size_t");
2777 Builder.AddTypedTextChunk(
"alignof");
2779 Builder.AddPlaceholderChunk(
"type");
2781 Results.AddResult(
Result(Builder.TakeString()));
2784 Builder.AddResultTypeChunk(
"bool");
2785 Builder.AddTypedTextChunk(
"noexcept");
2787 Builder.AddPlaceholderChunk(
"expression");
2789 Results.AddResult(
Result(Builder.TakeString()));
2792 Builder.AddResultTypeChunk(
"size_t");
2793 Builder.AddTypedTextChunk(
"sizeof...");
2795 Builder.AddPlaceholderChunk(
"parameter-pack");
2797 Results.AddResult(
Result(Builder.TakeString()));
2802 Builder.AddTypedTextChunk(
"co_await");
2804 Builder.AddPlaceholderChunk(
"expression");
2805 Results.AddResult(
Result(Builder.TakeString()));
2808 Builder.AddTypedTextChunk(
"co_yield");
2810 Builder.AddPlaceholderChunk(
"expression");
2811 Results.AddResult(
Result(Builder.TakeString()));
2814 Builder.AddResultTypeChunk(
"bool");
2815 Builder.AddTypedTextChunk(
"requires");
2818 Builder.AddPlaceholderChunk(
"parameters");
2823 Builder.AddPlaceholderChunk(
"requirements");
2826 Results.AddResult(
Result(Builder.TakeString()));
2830 Builder.AddTypedTextChunk(
"requires");
2832 Builder.AddPlaceholderChunk(
"expression");
2834 Results.AddResult(
Result(Builder.TakeString()));
2844 if (ID->getSuperClass()) {
2845 std::string SuperType;
2846 SuperType = ID->getSuperClass()->getNameAsString();
2847 if (Method->isInstanceMethod())
2850 Builder.AddResultTypeChunk(Allocator.CopyString(SuperType));
2851 Builder.AddTypedTextChunk(
"super");
2852 Results.AddResult(
Result(Builder.TakeString()));
2861 Builder.AddResultTypeChunk(
"size_t");
2863 Builder.AddTypedTextChunk(
"alignof");
2865 Builder.AddTypedTextChunk(
"_Alignof");
2867 Builder.AddPlaceholderChunk(
"type");
2869 Results.AddResult(
Result(Builder.TakeString()));
2874 Builder.AddResultTypeChunk(
"nullptr_t");
2875 Builder.AddTypedTextChunk(
"nullptr");
2876 Results.AddResult(
Result(Builder.TakeString()));
2880 Builder.AddResultTypeChunk(
"size_t");
2881 Builder.AddTypedTextChunk(
"sizeof");
2883 Builder.AddPlaceholderChunk(
"expression-or-type");
2885 Results.AddResult(
Result(Builder.TakeString()));
2898 Results.AddResult(
Result(
"operator"));
2919 else if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2921 T = Method->getSendResultType(BaseType);
2924 }
else if (
const auto *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2927 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2929 }
else if (
const auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2931 T = Ivar->getUsageType(BaseType);
2933 T = Ivar->getType();
2934 }
else if (
const auto *
Value = dyn_cast<ValueDecl>(ND)) {
2936 }
else if (
const auto *
Property = dyn_cast<ObjCPropertyDecl>(ND)) {
2946 Result.AddResultTypeChunk(
2953 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2954 if (Sentinel->getSentinel() == 0) {
2956 Result.AddTextChunk(
", nil");
2958 Result.AddTextChunk(
", NULL");
2960 Result.AddTextChunk(
", (void*)0");
2981 switch (*nullability) {
2991 Result +=
"null_unspecified ";
2995 llvm_unreachable(
"Not supported as a context-sensitive keyword!");
3012 bool SuppressBlock =
false) {
3018 if (!SuppressBlock) {
3021 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
3034 TL = AttrTL.getModifiedLoc();
3053 bool SuppressBlockName =
false,
bool SuppressBlock =
false,
3058 bool SuppressName =
false,
bool SuppressBlock =
false,
3066 if (
const auto *PVD = dyn_cast<ParmVarDecl>(Param))
3067 ObjCQual = PVD->getObjCDeclQualifier();
3068 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
3075 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
3082 if (ObjCMethodParam) {
3101 if (!
Block && ObjCMethodParam &&
3102 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
3103 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
3104 ->findPropertyDecl(
false))
3118 if (ObjCMethodParam) {
3123 if (
Result.back() !=
')')
3137 false, SuppressBlock,
3153 bool SuppressBlockName,
bool SuppressBlock,
3161 if (!ResultType->
isVoidType() || SuppressBlock)
3166 if (!BlockProto ||
Block.getNumParams() == 0) {
3173 for (
unsigned I = 0, N =
Block.getNumParams(); I != N; ++I) {
3186 if (SuppressBlock) {
3189 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3198 if (!SuppressBlockName &&
BlockDecl->getIdentifier())
3218 if (srcText.empty() || srcText ==
"=") {
3224 std::string DefValue(srcText.str());
3227 if (DefValue.at(0) !=
'=') {
3231 return " = " + DefValue;
3233 return " " + DefValue;
3242 bool InOptional =
false) {
3243 bool FirstParameter =
true;
3245 for (
unsigned P = Start, N =
Function->getNumParams();
P != N; ++
P) {
3252 Result.getCodeCompletionTUInfo());
3253 if (!FirstParameter)
3261 FirstParameter =
false;
3273 if (
Function->isVariadic() &&
P == N - 1)
3274 PlaceholderStr +=
", ...";
3277 Result.AddPlaceholderChunk(
3278 Result.getAllocator().CopyString(PlaceholderStr));
3282 if (Proto->isVariadic()) {
3283 if (Proto->getNumParams() == 0)
3284 Result.AddPlaceholderChunk(
"...");
3294 unsigned MaxParameters = 0,
unsigned Start = 0,
bool InDefaultArg =
false) {
3295 bool FirstParameter =
true;
3304 PEnd = Params->
begin() + MaxParameters;
3307 bool HasDefaultArg =
false;
3308 std::string PlaceholderStr;
3310 if (TTP->wasDeclaredWithTypename())
3311 PlaceholderStr =
"typename";
3312 else if (
const auto *TC = TTP->getTypeConstraint()) {
3313 llvm::raw_string_ostream OS(PlaceholderStr);
3314 TC->print(OS, Policy);
3316 PlaceholderStr =
"class";
3318 if (TTP->getIdentifier()) {
3319 PlaceholderStr +=
' ';
3320 PlaceholderStr += TTP->getIdentifier()->deuglifiedName();
3323 HasDefaultArg = TTP->hasDefaultArgument();
3325 dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
3326 if (NTTP->getIdentifier())
3327 PlaceholderStr = std::string(NTTP->getIdentifier()->deuglifiedName());
3328 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
3329 HasDefaultArg = NTTP->hasDefaultArgument();
3331 assert(isa<TemplateTemplateParmDecl>(*
P));
3336 PlaceholderStr =
"template<...> class";
3338 PlaceholderStr +=
' ';
3345 if (HasDefaultArg && !InDefaultArg) {
3349 Result.getCodeCompletionTUInfo());
3350 if (!FirstParameter)
3353 P - Params->
begin(),
true);
3358 InDefaultArg =
false;
3361 FirstParameter =
false;
3366 Result.AddPlaceholderChunk(
3367 Result.getAllocator().CopyString(PlaceholderStr));
3375 bool QualifierIsInformative,
3381 std::string PrintedNNS;
3383 llvm::raw_string_ostream OS(PrintedNNS);
3384 Qualifier->print(OS, Policy);
3386 if (QualifierIsInformative)
3387 Result.AddInformativeChunk(
Result.getAllocator().CopyString(PrintedNNS));
3389 Result.AddTextChunk(
Result.getAllocator().CopyString(PrintedNNS));
3396 if (!Proto || !Proto->getMethodQuals())
3402 if (Proto->getMethodQuals().hasOnlyConst()) {
3403 Result.AddInformativeChunk(
" const");
3407 if (Proto->getMethodQuals().hasOnlyVolatile()) {
3408 Result.AddInformativeChunk(
" volatile");
3412 if (Proto->getMethodQuals().hasOnlyRestrict()) {
3413 Result.AddInformativeChunk(
" restrict");
3418 std::string QualsStr;
3419 if (Proto->isConst())
3420 QualsStr +=
" const";
3421 if (Proto->isVolatile())
3422 QualsStr +=
" volatile";
3423 if (Proto->isRestrict())
3424 QualsStr +=
" restrict";
3425 Result.AddInformativeChunk(
Result.getAllocator().CopyString(QualsStr));
3436 switch (Name.getNameKind()) {
3438 const char *OperatorName =
nullptr;
3439 switch (Name.getCXXOverloadedOperator()) {
3441 case OO_Conditional:
3443 OperatorName =
"operator";
3446#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
3448 OperatorName = "operator" Spelling; \
3450#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly)
3451#include "clang/Basic/OperatorKinds.def"
3454 OperatorName =
"operator new";
3457 OperatorName =
"operator delete";
3460 OperatorName =
"operator new[]";
3462 case OO_Array_Delete:
3463 OperatorName =
"operator delete[]";
3466 OperatorName =
"operator()";
3469 OperatorName =
"operator[]";
3472 Result.AddTypedTextChunk(OperatorName);
3480 Result.AddTypedTextChunk(
3493 QualType Ty = Name.getCXXNameType();
3495 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
3497 Record = InjectedTy->getDecl();
3499 Result.AddTypedTextChunk(
3504 Result.AddTypedTextChunk(
3505 Result.getAllocator().CopyString(
Record->getNameAsString()));
3519 bool IncludeBriefComments) {
3521 CCTUInfo, IncludeBriefComments);
3533 return Result.TakeString();
3544 Result.AddPlaceholderChunk(
"...");
3558 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3563 Result.AddPlaceholderChunk(
3564 Result.getAllocator().CopyString((*A)->getName()));
3567 return Result.TakeString();
3579 bool IncludeBriefComments) {
3595 Result.addBriefComment(RC->getBriefText(Ctx));
3605 return Result.TakeString();
3609 PP, Ctx,
Result, IncludeBriefComments, CCContext, Policy);
3613 std::string &BeforeName,
3614 std::string &NameAndSignature) {
3615 bool SeenTypedChunk =
false;
3616 for (
auto &Chunk : CCS) {
3618 assert(SeenTypedChunk &&
"optional parameter before name");
3625 NameAndSignature += Chunk.Text;
3627 BeforeName += Chunk.Text;
3639 std::string BeforeName;
3640 std::string NameAndSignature;
3643 NameAndSignature +=
" override";
3645 Result.AddTextChunk(
Result.getAllocator().CopyString(BeforeName));
3647 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(NameAndSignature));
3648 return Result.TakeString();
3654 const auto *VD = dyn_cast<VarDecl>(ND);
3657 const auto *
RecordDecl = VD->getType()->getAsCXXRecordDecl();
3670 if (IncludeBriefComments) {
3673 Result.addBriefComment(RC->getBriefText(Ctx));
3678 Result.AddTypedTextChunk(
3680 Result.AddTextChunk(
"::");
3681 return Result.TakeString();
3685 Result.AddAnnotation(
Result.getAllocator().CopyString(I->getAnnotation()));
3698 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND)) {
3699 AddFunctionTypeAndResult(
Function);
3700 return Result.TakeString();
3703 if (
const auto *CallOperator =
3705 AddFunctionTypeAndResult(CallOperator);
3706 return Result.TakeString();
3712 dyn_cast<FunctionTemplateDecl>(ND)) {
3723 llvm::SmallBitVector Deduced(FunTmpl->getTemplateParameters()->size());
3728 unsigned LastDeducibleArgument;
3729 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
3730 --LastDeducibleArgument) {
3731 if (!Deduced[LastDeducibleArgument - 1]) {
3735 bool HasDefaultArg =
false;
3736 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
3737 LastDeducibleArgument - 1);
3739 HasDefaultArg = TTP->hasDefaultArgument();
3741 dyn_cast<NonTypeTemplateParmDecl>(Param))
3742 HasDefaultArg = NTTP->hasDefaultArgument();
3744 assert(isa<TemplateTemplateParmDecl>(Param));
3746 cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
3769 LastDeducibleArgument);
3778 return Result.TakeString();
3781 if (
const auto *Template = dyn_cast<TemplateDecl>(ND)) {
3784 Result.AddTypedTextChunk(
3785 Result.getAllocator().CopyString(Template->getNameAsString()));
3789 return Result.TakeString();
3792 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(ND)) {
3793 Selector Sel = Method->getSelector();
3795 Result.AddTypedTextChunk(
3797 return Result.TakeString();
3803 Result.AddTypedTextChunk(
Result.getAllocator().CopyString(SelName));
3805 Result.AddInformativeChunk(
Result.getAllocator().CopyString(SelName));
3810 Result.AddTypedTextChunk(
"");
3817 P != PEnd && Idx < Sel.
getNumArgs(); (
void)++
P, ++Idx) {
3836 QualType ParamType = (*P)->getType();
3837 std::optional<ArrayRef<QualType>> ObjCSubsts;
3853 Arg += II->getName();
3860 Result.AddTextChunk(
Result.getAllocator().CopyString(Arg));
3862 Result.AddInformativeChunk(
Result.getAllocator().CopyString(Arg));
3864 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Arg));
3870 Result.AddTextChunk(
", ...");
3872 Result.AddInformativeChunk(
", ...");
3874 Result.AddPlaceholderChunk(
", ...");
3880 return Result.TakeString();
3887 Result.AddTypedTextChunk(
3889 return Result.TakeString();
3900 const auto *M = dyn_cast<ObjCMethodDecl>(ND);
3912 const auto *M = dyn_cast_or_null<ObjCMethodDecl>(ND);
3913 if (!M || !M->isPropertyAccessor())
3936 auto FDecl =
Result.getFunction();
3939 if (ArgIndex < FDecl->getNumParams())
3947 unsigned CurrentArg) {
3948 unsigned ChunkIndex = 0;
3949 auto AddChunk = [&](llvm::StringRef Placeholder) {
3952 const char *
Copy =
Result.getAllocator().CopyString(Placeholder);
3953 if (ChunkIndex == CurrentArg)
3961 if (
auto *CRD = llvm::dyn_cast<CXXRecordDecl>(RD)) {
3962 for (
const auto &
Base : CRD->bases())
3963 AddChunk(
Base.getType().getAsString(Policy));
3965 for (
const auto &Field : RD->
fields())
3975 unsigned CurrentArg,
unsigned Start = 0,
bool InOptional =
false) {
3981 bool FirstParameter =
true;
3982 unsigned NumParams =
3985 for (
unsigned P = Start;
P != NumParams; ++
P) {
3990 Result.getCodeCompletionTUInfo());
3991 if (!FirstParameter)
3995 PrototypeLoc, Opt, CurrentArg,
P,
4002 FirstParameter =
false;
4009 std::string Placeholder;
4010 assert(P < Prototype->getNumParams());
4019 Placeholder =
Prototype->getParamType(
P).getAsString(Policy);
4022 if (
P == CurrentArg)
4023 Result.AddCurrentParameterChunk(
4024 Result.getAllocator().CopyString(Placeholder));
4026 Result.AddPlaceholderChunk(
Result.getAllocator().CopyString(Placeholder));
4031 Result.getCodeCompletionTUInfo());
4032 if (!FirstParameter)
4035 if (CurrentArg < NumParams)
4047 if (
const auto *
Type = dyn_cast<TemplateTypeParmDecl>(Param)) {
4049 }
else if (
const auto *NonType = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
4050 Optional = NonType->hasDefaultArgument();
4051 }
else if (
const auto *Template = dyn_cast<TemplateTemplateParmDecl>(Param)) {
4052 Optional = Template->hasDefaultArgument();
4055 llvm::raw_string_ostream OS(
Result);
4056 Param->
print(OS, Policy);
4062 if (
const auto *CTD = dyn_cast<ClassTemplateDecl>(TD))
4063 return CTD->getTemplatedDecl()->getKindName().str();
4064 if (
const auto *VTD = dyn_cast<VarTemplateDecl>(TD))
4065 return VTD->getTemplatedDecl()->getType().getAsString(Policy);
4066 if (
const auto *FTD = dyn_cast<FunctionTemplateDecl>(TD))
4067 return FTD->getTemplatedDecl()->getReturnType().getAsString(Policy);
4068 if (isa<TypeAliasTemplateDecl>(TD))
4070 if (isa<TemplateTemplateParmDecl>(TD))
4072 if (isa<ConceptDecl>(TD))
4082 Builder.getCodeCompletionTUInfo());
4084 if (!ResultType.empty())
4085 Builder.AddResultTypeChunk(Builder.getAllocator().CopyString(ResultType));
4086 Builder.AddTextChunk(
4092 for (
unsigned I = 0; I < Params.size(); ++I) {
4094 std::string Placeholder =
4097 Current = &OptionalBuilder;
4100 Current->AddChunk(I == CurrentArg
4103 Current->getAllocator().CopyString(Placeholder));
4106 if (Current == &OptionalBuilder)
4107 Builder.AddOptionalChunk(OptionalBuilder.
TakeString());
4111 if (isa<FunctionTemplateDecl>(TD))
4112 Builder.AddInformativeChunk(
"()");
4113 return Builder.TakeString();
4120 bool Braced)
const {
4144 if (IncludeBriefComments) {
4151 llvm::raw_string_ostream OS(Name);
4153 Result.AddTextChunk(
Result.getAllocator().CopyString(Name));
4156 Result.AddResultTypeChunk(
Result.getAllocator().CopyString(
4171 return Result.TakeString();
4176 bool PreferredTypeIsPointer) {
4180 if (MacroName ==
"nil" || MacroName ==
"NULL" || MacroName ==
"Nil") {
4182 if (PreferredTypeIsPointer)
4186 else if (MacroName ==
"YES" || MacroName ==
"NO" || MacroName ==
"true" ||
4187 MacroName ==
"false")
4190 else if (MacroName ==
"bool")
4203 case Decl::EnumConstant:
4207 case Decl::Function:
4209 case Decl::ObjCCategory:
4211 case Decl::ObjCCategoryImpl:
4213 case Decl::ObjCImplementation:
4216 case Decl::ObjCInterface:
4218 case Decl::ObjCIvar:
4220 case Decl::ObjCMethod:
4221 return cast<ObjCMethodDecl>(
D)->isInstanceMethod()
4224 case Decl::CXXMethod:
4226 case Decl::CXXConstructor:
4228 case Decl::CXXDestructor:
4230 case Decl::CXXConversion:
4232 case Decl::ObjCProperty:
4234 case Decl::ObjCProtocol:
4240 case Decl::TypeAlias:
4242 case Decl::TypeAliasTemplate:
4246 case Decl::Namespace:
4248 case Decl::NamespaceAlias:
4250 case Decl::TemplateTypeParm:
4252 case Decl::NonTypeTemplateParm:
4254 case Decl::TemplateTemplateParm:
4256 case Decl::FunctionTemplate:
4258 case Decl::ClassTemplate:
4260 case Decl::AccessSpec:
4262 case Decl::ClassTemplatePartialSpecialization:
4264 case Decl::UsingDirective:
4266 case Decl::StaticAssert:
4270 case Decl::TranslationUnit:
4274 case Decl::UnresolvedUsingValue:
4275 case Decl::UnresolvedUsingTypename:
4278 case Decl::UsingEnum:
4281 case Decl::ObjCPropertyImpl:
4282 switch (cast<ObjCPropertyImplDecl>(
D)->getPropertyImplementation()) {
4289 llvm_unreachable(
"Unexpected Kind!");
4294 case Decl::ObjCTypeParam:
4300 case Decl::LinkageSpec:
4304 if (
const auto *TD = dyn_cast<TagDecl>(
D)) {
4305 switch (TD->getTagKind()) {
4323 bool LoadExternal,
bool IncludeUndefined,
4324 bool TargetTypeIsPointer =
false) {
4327 Results.EnterNewScope();
4333 if (IncludeUndefined || MD) {
4341 TargetTypeIsPointer)));
4345 Results.ExitScope();
4349 ResultBuilder &Results) {
4352 Results.EnterNewScope();
4356 if (LangOpts.C99 || LangOpts.CPlusPlus11)
4358 Results.ExitScope();
4365 unsigned NumResults) {
4428 llvm_unreachable(
"Invalid ParserCompletionContext!");
4440 ResultBuilder &Results) {
4443 while (isa<BlockDecl>(CurContext))
4446 CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(CurContext);
4453 if (!
P->getDeclName())
4459 Results.getCodeCompletionTUInfo());
4466 S.
Context, CurContext, Overridden->getDeclContext());
4469 llvm::raw_string_ostream OS(Str);
4470 NNS->
print(OS, Policy);
4471 Builder.AddTextChunk(Results.getAllocator().CopyString(Str));
4473 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
4476 Builder.AddTypedTextChunk(
4477 Results.getAllocator().CopyString(Overridden->getNameAsString()));
4479 bool FirstParam =
true;
4486 Builder.AddPlaceholderChunk(
4487 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
4493 Results.Ignore(Overridden);
4500 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4501 CodeCompleter->getCodeCompletionTUInfo(),
4503 Results.EnterNewScope();
4512 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
4513 Builder.AddTypedTextChunk(
4514 Builder.getAllocator().CopyString(Modules[I]->Name));
4515 Results.AddResult(
Result(
4520 }
else if (getLangOpts().Modules) {
4528 Builder.AddTypedTextChunk(
4529 Builder.getAllocator().CopyString(Submodule->Name));
4530 Results.AddResult(
Result(
4537 Results.ExitScope();
4539 Results.getCompletionContext(), Results.data(),
4545 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4546 CodeCompleter->getCodeCompletionTUInfo(),
4548 Results.EnterNewScope();
4553 switch (CompletionContext) {
4556 case PCC_ObjCInterface:
4557 case PCC_ObjCImplementation:
4558 case PCC_ObjCInstanceVariableList:
4560 case PCC_MemberTemplate:
4562 case PCC_LocalDeclarationSpecifiers:
4563 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
4567 case PCC_TopLevelOrExpression:
4568 case PCC_ParenthesizedExpression:
4569 case PCC_Expression:
4573 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4575 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4581 case PCC_RecoveryInFunction:
4589 if (!ThisType.isNull())
4590 Results.setObjectTypeQualifiers(ThisType->getPointeeType().getQualifiers(),
4593 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4595 CodeCompleter->includeGlobals(),
4596 CodeCompleter->loadExternal());
4599 Results.ExitScope();
4601 switch (CompletionContext) {
4602 case PCC_ParenthesizedExpression:
4603 case PCC_Expression:
4605 case PCC_TopLevelOrExpression:
4606 case PCC_RecoveryInFunction:
4607 if (S->getFnParent())
4613 case PCC_ObjCInterface:
4614 case PCC_ObjCImplementation:
4615 case PCC_ObjCInstanceVariableList:
4617 case PCC_MemberTemplate:
4621 case PCC_LocalDeclarationSpecifiers:
4625 if (CodeCompleter->includeMacros())
4629 Results.getCompletionContext(), Results.data(),
4636 bool AtArgumentExpression,
bool IsSuper,
4637 ResultBuilder &Results);
4640 bool AllowNonIdentifiers,
4641 bool AllowNestedNameSpecifiers) {
4643 ResultBuilder Results(
4644 SemaRef, CodeCompleter->getAllocator(),
4645 CodeCompleter->getCodeCompletionTUInfo(),
4646 AllowNestedNameSpecifiers
4651 Results.EnterNewScope();
4654 Results.AddResult(
Result(
"const"));
4655 Results.AddResult(
Result(
"volatile"));
4656 if (getLangOpts().
C99)
4657 Results.AddResult(
Result(
"restrict"));
4663 Results.AddResult(
"final");
4665 if (AllowNonIdentifiers) {
4666 Results.AddResult(
Result(
"operator"));
4670 if (AllowNestedNameSpecifiers) {
4671 Results.allowNestedNameSpecifiers();
4672 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
4673 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
4675 Consumer, CodeCompleter->includeGlobals(),
4676 CodeCompleter->loadExternal());
4677 Results.setFilter(
nullptr);
4680 Results.ExitScope();
4686 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
4705 Results.getCompletionContext(), Results.data(),
4710 if (
Scope ==
"clang")
4718 if (
Scope ==
"_Clang")
4720 if (
Scope ==
"__gnu__")
4728 if (Completion == AttributeCompletion::None)
4730 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
4731 CodeCompleter->getCodeCompletionTUInfo(),
4744 llvm::StringRef InScopeName;
4745 bool InScopeUnderscore =
false;
4747 InScopeName = InScope->
getName();
4749 InScopeName = NoUnderscore;
4750 InScopeUnderscore =
true;
4757 llvm::DenseSet<llvm::StringRef> FoundScopes;
4759 if (A.IsTargetSpecific &&
4760 !A.existsInTarget(getASTContext().getTargetInfo()))
4762 if (!A.acceptsLangOpts(getLangOpts()))
4764 for (
const auto &S : A.Spellings) {
4765 if (S.Syntax != Syntax)
4767 llvm::StringRef Name = S.NormalizedFullName;
4768 llvm::StringRef
Scope;
4771 std::tie(
Scope, Name) = Name.split(
"::");
4773 std::swap(Name,
Scope);
4777 if (Completion == AttributeCompletion::Scope) {
4779 if (!
Scope.empty() && FoundScopes.insert(
Scope).second) {
4790 if (!InScopeName.empty()) {
4791 if (
Scope != InScopeName)
4796 auto Add = [&](llvm::StringRef
Scope, llvm::StringRef Name,
4799 Results.getCodeCompletionTUInfo());
4801 if (!
Scope.empty()) {
4810 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
Text));
4812 if (!A.ArgNames.empty()) {
4815 for (
const char *Arg : A.ArgNames) {
4819 Builder.AddPlaceholderChunk(Arg);
4824 Results.AddResult(Builder.TakeString());
4831 if (!InScopeUnderscore)
4832 Add(
Scope, Name,
false);
4837 if (!(InScope && !InScopeUnderscore) && SyntaxSupportsGuards) {
4839 if (
Scope.empty()) {
4840 Add(
Scope, Name,
true);
4845 Add(GuardedScope, Name,
true);
4855 for (
const auto &Entry : ParsedAttrInfoRegistry::entries())
4856 AddCompletions(*Entry.instantiate());
4859 Results.getCompletionContext(), Results.data(),
4865 bool IsParenthesized =
false)
4866 : PreferredType(PreferredType), IntegralConstantExpression(
false),
4867 ObjCCollection(
false), IsParenthesized(IsParenthesized) {}
4878struct CoveredEnumerators {
4886 const CoveredEnumerators &Enumerators) {
4888 if (Context.
getLangOpts().CPlusPlus && !Qualifier && Enumerators.Seen.empty()) {
4895 Results.EnterNewScope();
4896 for (
auto *
E :
Enum->enumerators()) {
4897 if (Enumerators.Seen.count(
E))
4901 Results.AddResult(R, CurContext,
nullptr,
false);
4903 Results.ExitScope();
4909 assert(!
T.isNull());
4932 if (!Results.includeCodePatterns())
4935 Results.getCodeCompletionTUInfo());
4940 if (!Parameters.empty()) {
4949 constexpr llvm::StringLiteral NamePlaceholder =
"!#!NAME_GOES_HERE!#!";
4950 std::string
Type = std::string(NamePlaceholder);
4952 llvm::StringRef Prefix, Suffix;
4953 std::tie(Prefix, Suffix) = llvm::StringRef(
Type).split(NamePlaceholder);
4954 Prefix = Prefix.rtrim();
4955 Suffix = Suffix.ltrim();
4978 ResultBuilder Results(
4979 SemaRef, CodeCompleter->getAllocator(),
4980 CodeCompleter->getCodeCompletionTUInfo(),
4982 Data.IsParenthesized
4985 Data.PreferredType));
4987 Data.IsParenthesized ? PCC_ParenthesizedExpression : PCC_Expression;
4988 if (
Data.ObjCCollection)
4989 Results.setFilter(&ResultBuilder::IsObjCCollection);
4990 else if (
Data.IntegralConstantExpression)
4991 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
4993 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4995 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
4997 if (!
Data.PreferredType.isNull())
4998 Results.setPreferredType(
Data.PreferredType.getNonReferenceType());
5001 for (
unsigned I = 0, N =
Data.IgnoreDecls.size(); I != N; ++I)
5002 Results.Ignore(
Data.IgnoreDecls[I]);
5004 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
5006 CodeCompleter->includeGlobals(),
5007 CodeCompleter->loadExternal());
5009 Results.EnterNewScope();
5011 Results.ExitScope();
5013 bool PreferredTypeIsPointer =
false;
5014 if (!
Data.PreferredType.isNull()) {
5015 PreferredTypeIsPointer =
Data.PreferredType->isAnyPointerType() ||
5016 Data.PreferredType->isMemberPointerType() ||
5017 Data.PreferredType->isBlockPointerType();
5018 if (
Data.PreferredType->isEnumeralType()) {
5020 if (
auto *Def =
Enum->getDefinition())
5025 CoveredEnumerators());
5029 if (S->getFnParent() && !
Data.ObjCCollection &&
5030 !
Data.IntegralConstantExpression)
5033 if (CodeCompleter->includeMacros())
5035 PreferredTypeIsPointer);
5045 Results.getCompletionContext(), Results.data(),
5051 bool IsParenthesized) {
5052 return CodeCompleteExpression(
5059 CodeCompleteExpression(S, PreferredType);
5060 else if (getLangOpts().
ObjC)
5061 CodeCompleteObjCInstanceMessage(S,
E.get(), {},
false);
5078 if (Protocol->hasDefinition())
5079 return Protocol->getDefinition();
5093 Builder.AddResultTypeChunk(
5095 Policy, Builder.getAllocator()));
5101 Builder.AddPlaceholderChunk(
"...");
5103 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
5108 std::string PlaceholderStr =
5111 if (I == N - 1 && BlockProtoLoc &&
5113 PlaceholderStr +=
", ...";
5116 Builder.AddPlaceholderChunk(
5117 Builder.getAllocator().CopyString(PlaceholderStr));
5127 bool AllowNullaryMethods,
DeclContext *CurContext,
5129 bool IsBaseExprStatement =
false,
5130 bool IsClassProperty =
false,
bool InOriginalClass =
true) {
5138 if (!AddedProperties.insert(
P->getIdentifier()).second)
5143 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
5144 !IsBaseExprStatement) {
5146 if (!InOriginalClass)
5148 Results.MaybeAddResult(R, CurContext);
5160 if (!InOriginalClass)
5162 Results.MaybeAddResult(R, CurContext);
5169 Results.getCodeCompletionTUInfo());
5172 BlockLoc, BlockProtoLoc);
5173 Result R =
Result(Builder.TakeString(),
P, Results.getBasePriority(
P));
5174 if (!InOriginalClass)
5176 Results.MaybeAddResult(R, CurContext);
5180 if (!
P->isReadOnly()) {
5182 Results.getCodeCompletionTUInfo());
5186 Builder.AddTypedTextChunk(
5187 Results.getAllocator().CopyString(
P->getName()));
5192 BlockProtoLoc,
true);
5194 Builder.AddPlaceholderChunk(
5195 Builder.getAllocator().CopyString(PlaceholderStr));
5203 Result(Builder.TakeString(),
P,
5204 Results.getBasePriority(
P) +
5208 if (!InOriginalClass)
5210 Results.MaybeAddResult(R, CurContext);
5214 if (IsClassProperty) {
5215 for (
const auto *
P : Container->class_properties())
5218 for (
const auto *
P : Container->instance_properties())
5223 if (AllowNullaryMethods) {
5224 ASTContext &Context = Container->getASTContext();
5228 const IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
5231 if (!AddedProperties.insert(Name).second)
5234 Results.getCodeCompletionTUInfo());
5236 Builder.AddTypedTextChunk(
5237 Results.getAllocator().CopyString(Name->getName()));
5240 if (!InOriginalClass)
5242 Results.MaybeAddResult(R, CurContext);
5245 if (IsClassProperty) {
5246 for (
const auto *M : Container->methods()) {
5250 if (!M->getSelector().isUnarySelector() ||
5251 M->getReturnType()->isVoidType() || M->isInstanceMethod())
5256 for (
auto *M : Container->methods()) {
5257 if (M->getSelector().isUnarySelector())
5265 for (
auto *
P : Protocol->protocols())
5267 CurContext, AddedProperties, Results,
5268 IsBaseExprStatement, IsClassProperty,
5271 dyn_cast<ObjCInterfaceDecl>(Container)) {
5272 if (AllowCategories) {
5274 for (
auto *Cat : IFace->known_categories())
5276 CurContext, AddedProperties, Results,
5277 IsBaseExprStatement, IsClassProperty,
5282 for (
auto *I : IFace->all_referenced_protocols())
5284 CurContext, AddedProperties, Results,
5285 IsBaseExprStatement, IsClassProperty,
5289 if (IFace->getSuperClass())
5291 AllowNullaryMethods, CurContext, AddedProperties,
5292 Results, IsBaseExprStatement, IsClassProperty,
5295 dyn_cast<ObjCCategoryDecl>(Container)) {
5299 CurContext, AddedProperties, Results,
5300 IsBaseExprStatement, IsClassProperty,
5309 std::optional<FixItHint> AccessOpFixIt) {
5312 Results.setObjectTypeQualifiers(BaseType.
getQualifiers(), BaseKind);
5315 Results.allowNestedNameSpecifiers();
5316 std::vector<FixItHint> FixIts;
5318 FixIts.emplace_back(*AccessOpFixIt);
5319 CodeCompletionDeclConsumer Consumer(Results, RD, BaseType, std::move(FixIts));
5327 if (!Results.empty()) {
5333 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->getParent())
5335 IsDependent = Ctx->isDependentContext();
5352 if (
const auto *CTSD =
5353 llvm::dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
5357 RD = CTSD->getSpecializedTemplate()->getTemplatedDecl();
5363 if (
const auto *TD = dyn_cast_or_null<ClassTemplateDecl>(
5364 TST->getTemplateName().getAsTemplateDecl())) {
5365 return TD->getTemplatedDecl();
5409 std::optional<SmallVector<QualType, 1>> ArgTypes;
5411 enum AccessOperator {
5428 std::string AsString;
5430 llvm::raw_string_ostream OS(AsString);
5431 QualType ExactType = deduceType(*ResultType);
5437 B.AddResultTypeChunk(
Alloc.CopyString(AsString));
5440 B.AddTypedTextChunk(
Alloc.CopyString(Name->getName()));
5452 B.AddPlaceholderChunk(
Alloc.CopyString(
5457 return B.TakeString();
5465 auto *TemplatedEntity = getTemplatedEntity(BaseType.
getDecl(), S);
5466 for (
const Expr *
E : constraintsForTemplatedEntity(TemplatedEntity))
5467 believe(
E, &BaseType);
5470 std::vector<Member> members() {
5471 std::vector<Member> Results;
5472 for (
const auto &
E : this->Results)
5473 Results.push_back(
E.second);
5474 llvm::sort(Results, [](
const Member &L,
const Member &R) {
5475 return L.Name->getName() < R.Name->getName();
5485 if (
auto *CSE = dyn_cast<ConceptSpecializationExpr>(
E)) {
5499 for (
const auto &Arg : CSE->getTemplateArguments()) {
5500 if (Index >= Params->
size())
5502 if (isApprox(Arg,
T)) {
5503 auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Params->
getParam(Index));
5507 auto *TT = cast<TemplateTypeParmType>(TTPD->getTypeForDecl());
5515 }
else if (
auto *BO = dyn_cast<BinaryOperator>(
E)) {
5518 if (BO->getOpcode() == BO_LAnd || BO->getOpcode() == BO_LOr) {
5519 believe(BO->getLHS(),
T);
5520 believe(BO->getRHS(),
T);
5522 }
else if (
auto *RE = dyn_cast<RequiresExpr>(
E)) {
5525 if (!Req->isDependent())
5529 if (
auto *TR = dyn_cast<concepts::TypeRequirement>(Req)) {
5531 QualType AssertedType = TR->getType()->getType();
5532 ValidVisitor(
this,
T).TraverseType(AssertedType);
5533 }
else if (
auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
5534 ValidVisitor Visitor(
this,
T);
5538 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
5540 ER->getReturnTypeRequirement().getTypeConstraint();
5541 Visitor.OuterExpr = ER->getExpr();
5543 Visitor.TraverseStmt(ER->getExpr());
5544 }
else if (
auto *NR = dyn_cast<concepts::NestedRequirement>(Req)) {
5545 believe(NR->getConstraintExpr(),
T);
5562 Expr *OuterExpr =
nullptr;
5566 : Outer(Outer),
T(
T) {
5573 const Type *
Base =
E->getBaseType().getTypePtr();
5574 bool IsArrow =
E->isArrow();
5575 if (
Base->isPointerType() && IsArrow) {
5577 Base =
Base->getPointeeType().getTypePtr();
5579 if (isApprox(
Base,
T))
5580 addValue(
E,
E->getMember(), IsArrow ? Member::Arrow : Member::Dot);
5586 if (
E->getQualifier() && isApprox(
E->getQualifier()->getAsType(),
T))
5587 addValue(
E,
E->getDeclName(), Member::Colons);
5594 if (Q && isApprox(Q->getAsType(),
T))
5605 if (Q && isApprox(Q->getAsType(),
T))
5616 bool VisitCallExpr(
CallExpr *CE)
override {
5623 void addResult(
Member &&M) {
5624 auto R = Outer->Results.try_emplace(M.Name);
5625 Member &O = R.first->second;
5629 std::make_tuple(M.ArgTypes.has_value(), M.ResultType !=
nullptr,
5630 M.Operator) > std::make_tuple(O.ArgTypes.has_value(),
5631 O.ResultType !=
nullptr,
5641 M.Operator = Member::Colons;
5642 addResult(std::move(M));
5646 Member::AccessOperator Operator) {
5647 if (!Name.isIdentifier())
5650 Result.Name = Name.getAsIdentifierInfo();
5651 Result.Operator = Operator;
5654 if (Caller !=
nullptr && Callee ==
E) {
5655 Result.ArgTypes.emplace();
5656 for (
const auto *Arg : Caller->
arguments())
5657 Result.ArgTypes->push_back(Arg->getType());
5658 if (Caller == OuterExpr) {
5659 Result.ResultType = OuterType;
5663 Result.ResultType = OuterType;
5665 addResult(std::move(Result));
5674 static bool isApprox(
const Type *T1,
const Type *T2) {
5687 Scope *Inner =
nullptr;
5689 if (S->isTemplateParamScope() && S->isDeclScope(
D))
5690 return Inner ? Inner->getEntity() :
nullptr;
5706 TD->getAssociatedConstraints(Result);
5708 if (
const auto *CTPSD =
5709 dyn_cast<ClassTemplatePartialSpecializationDecl>(DC))
5710 CTPSD->getAssociatedConstraints(Result);
5711 if (
const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl>(DC))
5712 VTPSD->getAssociatedConstraints(Result);
5723 if (
const auto *Args =
T.getTemplateArgsAsWritten())
5724 if (Args->getNumTemplateArgs() == 1) {
5725 const auto &Arg = Args->arguments().front().getArgument();
5732 llvm::DenseMap<const IdentifierInfo *, Member> Results;
5747 Decls.size() == 1) {
5748 if (
const auto *TD = dyn_cast<TypeDecl>(Decls[0]))
5749 return QualType(TD->getTypeForDecl(), 0);
5753 if (!
Unresolved->isSpecificBuiltinType(BuiltinType::Dependent)) {
5755 if (!
Auto || !
Auto->isUndeducedAutoType())
5759 if (
const CallExpr *CE = llvm::dyn_cast<CallExpr>(
E)) {
5762 Callee->isSpecificPlaceholderType(BuiltinType::BoundMember))
5768 Callee = FnTypePtr->getPointeeType();
5770 Callee = BPT->getPointeeType();
5773 return FnType->getReturnType().getNonReferenceType();
5776 if (
const auto *OE = llvm::dyn_cast<OverloadExpr>(CE->
getCallee())) {
5780 const Type *Common =
nullptr;
5781 for (
const auto *
D : OE->decls()) {
5783 if (
const auto *FD = llvm::dyn_cast<FunctionDecl>(
D))
5784 ReturnType = FD->getReturnType();
5785 else if (
const auto *FTD = llvm::dyn_cast<FunctionTemplateDecl>(
D))
5786 ReturnType = FTD->getTemplatedDecl()->getReturnType();
5789 const Type *Candidate =
5791 if (Common && Common != Candidate)
5795 if (Common !=
nullptr)
5800 if (
const auto *CDSME = llvm::dyn_cast<CXXDependentScopeMemberExpr>(
E)) {
5802 ? CDSME->getBaseType()
5803 : getApproximateType(CDSME->getBase(), Resolver);
5804 if (CDSME->isArrow() && !
Base.isNull())
5810 if (RD && RD->isCompleteDefinition()) {
5812 for (
const auto *
Member : RD->lookupDependentName(
5814 return llvm::isa<ValueDecl>(Member);
5816 return llvm::cast<ValueDecl>(
Member)->getType().getNonReferenceType();
5821 if (
const auto *DRE = llvm::dyn_cast<DeclRefExpr>(
E)) {
5822 if (
const auto *VD = llvm::dyn_cast<VarDecl>(DRE->getDecl())) {
5824 return getApproximateType(VD->getInit(), Resolver);
5827 if (
const auto *UO = llvm::dyn_cast<UnaryOperator>(
E)) {
5828 if (UO->getOpcode() == UnaryOperatorKind::UO_Deref) {
5832 getApproximateType(UO->getSubExpr(), Resolver)->getPointeeType();
5847 if (
auto *PLE = llvm::dyn_cast_or_null<ParenListExpr>(
Base)) {
5848 if (PLE->getNumExprs() == 0)
5850 Base = PLE->getExpr(PLE->getNumExprs() - 1);
5859 bool IsBaseExprStatement,
QualType PreferredType) {
5861 OtherOpBase = unwrapParenList(OtherOpBase);
5862 if (!
Base || !CodeCompleter)
5870 getApproximateType(ConvertedBase.
get(), Resolver);
5877 ConvertedBaseType = PointeeType;
5894 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5895 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
5896 &ResultBuilder::IsMember);
5898 auto DoCompletion = [&](
Expr *
Base,
bool IsArrow,
5899 std::optional<FixItHint> AccessOpFixIt) ->
bool {
5909 QualType BaseType = getApproximateType(
Base, Resolver);
5917 BaseType = PointeeType;
5929 RD, std::move(AccessOpFixIt));
5930 }
else if (
const auto *TTPT =
5931 dyn_cast<TemplateTypeParmType>(BaseType.
getTypePtr())) {
5933 IsArrow ? ConceptInfo::Member::Arrow : ConceptInfo::Member::Dot;
5934 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
5935 if (R.Operator != Operator)
5938 R.render(SemaRef, CodeCompleter->getAllocator(),
5939 CodeCompleter->getCodeCompletionTUInfo()));
5941 Result.FixIts.push_back(*AccessOpFixIt);
5942 Results.AddResult(std::move(
Result));
5948 if (AccessOpFixIt) {
5956 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
5959 AddedProperties, Results, IsBaseExprStatement);
5965 SemaRef.
CurContext, AddedProperties, Results,
5966 IsBaseExprStatement,
false,
5973 if (AccessOpFixIt) {
5979 Class = ObjCPtr->getInterfaceDecl();
5985 CodeCompletionDeclConsumer Consumer(Results,
Class, BaseType);
5986 Results.setFilter(&ResultBuilder::IsObjCIvar);
5988 CodeCompleter->includeGlobals(),
5990 CodeCompleter->loadExternal());
5998 Results.EnterNewScope();
6000 bool CompletionSucceded = DoCompletion(
Base, IsArrow, std::nullopt);
6001 if (CodeCompleter->includeFixIts()) {
6004 CompletionSucceded |= DoCompletion(
6005 OtherOpBase, !IsArrow,
6009 Results.ExitScope();
6011 if (!CompletionSucceded)
6016 Results.getCompletionContext(), Results.data(),
6022 bool IsBaseExprStatement) {
6030 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6031 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
6032 &ResultBuilder::IsMember);
6033 Results.EnterNewScope();
6037 AddedProperties, Results, IsBaseExprStatement,
6039 Results.ExitScope();
6041 Results.getCompletionContext(), Results.data(),
6049 ResultBuilder::LookupFilter Filter =
nullptr;
6054 Filter = &ResultBuilder::IsEnum;
6059 Filter = &ResultBuilder::IsUnion;
6066 Filter = &ResultBuilder::IsClassOrStruct;
6071 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
6074 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6075 CodeCompleter->getCodeCompletionTUInfo(), ContextKind);
6076 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6079 Results.setFilter(Filter);
6081 CodeCompleter->includeGlobals(),
6082 CodeCompleter->loadExternal());
6084 if (CodeCompleter->includeGlobals()) {
6086 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
6088 CodeCompleter->includeGlobals(),
6089 CodeCompleter->loadExternal());
6093 Results.getCompletionContext(), Results.data(),
6100 Results.AddResult(
"const");
6102 Results.AddResult(
"volatile");
6104 Results.AddResult(
"restrict");
6106 Results.AddResult(
"_Atomic");
6108 Results.AddResult(
"__unaligned");
6112 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6113 CodeCompleter->getCodeCompletionTUInfo(),
6115 Results.EnterNewScope();
6117 Results.ExitScope();
6119 Results.getCompletionContext(), Results.data(),
6125 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6126 CodeCompleter->getCodeCompletionTUInfo(),
6128 Results.EnterNewScope();
6131 Results.AddResult(
"noexcept");
6133 !
D.isStaticMember()) {
6135 Results.AddResult(
"final");
6137 Results.AddResult(
"override");
6140 Results.ExitScope();
6142 Results.getCompletionContext(), Results.data(),
6147 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
6160 if (!
type->isEnumeralType()) {
6162 Data.IntegralConstantExpression =
true;
6163 CodeCompleteExpression(S,
Data);
6177 CoveredEnumerators Enumerators;
6179 SC = SC->getNextSwitchCase()) {
6180 CaseStmt *Case = dyn_cast<CaseStmt>(SC);
6185 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
6186 if (
auto *Enumerator =
6187 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
6194 Enumerators.Seen.insert(Enumerator);
6207 Enumerators.SuggestedQualifier = DRE->getQualifier();
6212 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6213 CodeCompleter->getCodeCompletionTUInfo(),
6218 if (CodeCompleter->includeMacros()) {
6222 Results.getCompletionContext(), Results.data(),
6227 if (Args.size() && !Args.data())
6230 for (
unsigned I = 0; I != Args.size(); ++I)
6251 if (Candidate.Function) {
6252 if (Candidate.Function->isDeleted())
6255 Candidate.Function) &&
6256 Candidate.Function->getNumParams() <= ArgSize &&
6265 if (Candidate.Viable)
6279 for (
auto &Candidate : Candidates) {
6280 QualType CandidateParamType = Candidate.getParamType(N);
6281 if (CandidateParamType.
isNull())
6283 if (ParamType.
isNull()) {
6284 ParamType = CandidateParamType;
6301 if (Candidates.empty())
6305 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc,
6316 if (
const auto *
T = Fn->getType().getTypePtr()->getAs<
TypedefType>()) {
6317 Target =
T->getDecl()->getTypeSourceInfo()->getTypeLoc();
6319 }
else if (
const auto *DR = dyn_cast<DeclRefExpr>(Fn)) {
6320 const auto *
D = DR->getDecl();
6321 if (
const auto *
const VD = dyn_cast<VarDecl>(
D)) {
6322 Target = VD->getTypeSourceInfo()->getTypeLoc();
6324 }
else if (
const auto *ME = dyn_cast<MemberExpr>(Fn)) {
6325 const auto *MD = ME->getMemberDecl();
6326 if (
const auto *FD = dyn_cast<FieldDecl>(MD)) {
6327 Target = FD->getTypeSourceInfo()->getTypeLoc();
6341 Target = A.getModifiedLoc();
6361 Fn = unwrapParenList(Fn);
6362 if (!CodeCompleter || !Fn)
6372 auto ArgsWithoutDependentTypes =
6377 Expr *NakedFn = Fn->IgnoreParenCasts();
6382 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
6386 }
else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
6388 if (UME->hasExplicitTemplateArgs()) {
6389 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
6390 TemplateArgs = &TemplateArgsBuffer;
6395 1, UME->isImplicitAccess() ?
nullptr : UME->getBase());
6396 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6397 ArgsWithoutDependentTypes.end());
6399 Decls.
append(UME->decls_begin(), UME->decls_end());
6400 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
6404 FirstArgumentIsBase);
6407 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
6408 FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl());
6409 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
6410 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
6418 ArgsWithoutDependentTypes, CandidateSet,
6428 getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
6433 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6434 ArgsWithoutDependentTypes.end());
6452 ArgsWithoutDependentTypes.size(),
6488static std::optional<unsigned>
6491 static constexpr unsigned Invalid = std::numeric_limits<unsigned>::max();
6497 unsigned ArgsAfterDesignator = 0;
6498 for (
const Expr *Arg : Args) {
6499 if (
const auto *DIE = dyn_cast<DesignatedInitExpr>(Arg)) {
6500 if (DIE->size() == 1 && DIE->getDesignator(0)->isFieldDesignator()) {
6501 DesignatedFieldName = DIE->getDesignator(0)->getFieldName();
6502 ArgsAfterDesignator = 0;
6506 }
else if (isa<DesignatedInitUpdateExpr>(Arg)) {
6509 ++ArgsAfterDesignator;
6512 if (!DesignatedFieldName)
6513 return std::nullopt;
6517 unsigned DesignatedIndex = 0;
6518 const FieldDecl *DesignatedField =
nullptr;
6519 for (
const auto *Field :
Aggregate.getAggregate()->fields()) {
6520 if (Field->getIdentifier() == DesignatedFieldName) {
6521 DesignatedField = Field;
6526 if (!DesignatedField)
6530 unsigned AggregateSize =
Aggregate.getNumParams();
6531 while (DesignatedIndex < AggregateSize &&
6532 Aggregate.getParamDecl(DesignatedIndex) != DesignatedField)
6536 return DesignatedIndex + ArgsAfterDesignator + 1;
6559 if (Braced && !RD->
isUnion() &&
6564 if (
auto NextIndex =
6567 if (*NextIndex >= AggregateSize)
6569 Results.push_back(AggregateSig);
6575 if (Args.size() < AggregateSize)
6576 Results.push_back(AggregateSig);
6585 if (
auto *FD = dyn_cast<FunctionDecl>(
C)) {
6588 if (Braced && getLangOpts().
CPlusPlus &&
6596 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
6597 if (Braced && getLangOpts().
CPlusPlus &&
6603 nullptr, Args, CandidateSet,
6624 dyn_cast<CXXConstructorDecl>(ConstructorDecl);
6629 Constructor->getParent(), SS, TemplateTypeTy, II))
6630 return ProduceConstructorSignatureHelp(MemberDecl->getType(),
6631 MemberDecl->getLocation(), ArgExprs,
6632 OpenParLoc, Braced);
6640 if (Index < Params.
size())
6643 Param = Params.
asArray().back();
6649 return llvm::isa<TemplateTypeParmDecl>(Param);
6651 return llvm::isa<NonTypeTemplateParmDecl>(Param);
6653 return llvm::isa<TemplateTemplateParmDecl>(Param);
6655 llvm_unreachable(
"Unhandled switch case");
6661 if (!CodeCompleter || !ParsedTemplate)
6667 bool Matches =
true;
6668 for (
unsigned I = 0; I < Args.size(); ++I) {
6675 Results.emplace_back(TD);
6683 if (
const auto *TD = llvm::dyn_cast<TemplateDecl>(ND))
6696 if (
D.isArrayDesignator() ||
D.isArrayRangeDesignator()) {
6700 assert(
D.isFieldDesignator());
6702 if (RD && RD->isCompleteDefinition()) {
6703 for (
const auto *
Member : RD->lookup(
D.getFieldDecl()))
6705 NextType = FD->getType();
6710 BaseType = NextType;
6721 if (!RD || RD->fields().empty())
6726 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6727 CodeCompleter->getCodeCompletionTUInfo(), CCC);
6729 Results.EnterNewScope();
6730 for (
const Decl *
D : RD->decls()) {
6732 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(
D))
6733 FD = IFD->getAnonField();
6734 else if (
auto *DFD = dyn_cast<FieldDecl>(
D))
6744 Results.ExitScope();
6746 Results.getCompletionContext(), Results.data(),
6751 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(
D);
6753 CodeCompleteOrdinaryName(S, PCC_Expression);
6760 Data.IgnoreDecls.push_back(VD);
6762 CodeCompleteExpression(S,
Data);
6766 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6767 CodeCompleter->getCodeCompletionTUInfo(),
6769 Results.setFilter(&ResultBuilder::IsOrdinaryName);
6770 Results.EnterNewScope();
6772 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6774 CodeCompleter->includeGlobals(),
6775 CodeCompleter->loadExternal());
6781 Results.getCodeCompletionTUInfo());
6783 auto AddElseBodyPattern = [&] {
6788 Builder.AddPlaceholderChunk(
"statements");
6794 Builder.AddPlaceholderChunk(
"statement");
6798 Builder.AddTypedTextChunk(
"else");
6799 if (Results.includeCodePatterns())
6800 AddElseBodyPattern();
6801 Results.AddResult(Builder.TakeString());
6804 Builder.AddTypedTextChunk(
"else if");
6808 Builder.AddPlaceholderChunk(
"condition");
6810 Builder.AddPlaceholderChunk(
"expression");
6812 if (Results.includeCodePatterns()) {
6813 AddElseBodyPattern();
6815 Results.AddResult(Builder.TakeString());
6817 Results.ExitScope();
6819 if (S->getFnParent())
6822 if (CodeCompleter->includeMacros())
6826 Results.getCompletionContext(), Results.data(),
6831 bool EnteringContext,
6832 bool IsUsingDeclaration,
6835 if (SS.
isEmpty() || !CodeCompleter)
6850 ResultBuilder DummyResults(SemaRef, CodeCompleter->getAllocator(),
6851 CodeCompleter->getCodeCompletionTUInfo(), CC);
6852 if (!PreferredType.
isNull())
6853 DummyResults.setPreferredType(PreferredType);
6854 if (S->getEntity()) {
6855 CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
6862 DummyResults.getCompletionContext(),
nullptr, 0);
6877 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6878 CodeCompleter->getCodeCompletionTUInfo(), CC);
6879 if (!PreferredType.
isNull())
6880 Results.setPreferredType(PreferredType);
6881 Results.EnterNewScope();
6886 if (!Results.empty() && NNS && NNS->
isDependent())
6887 Results.AddResult(
"template");
6892 if (
const auto *TTPT =
6893 dyn_cast_or_null<TemplateTypeParmType>(NNS->
getAsType())) {
6894 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
6895 if (R.Operator != ConceptInfo::Member::Colons)
6898 R.render(SemaRef, CodeCompleter->getAllocator(),
6899 CodeCompleter->getCodeCompletionTUInfo())));
6909 if (Ctx && !EnteringContext)
6911 Results.ExitScope();
6914 (CodeCompleter->includeNamespaceLevelDecls() || !Ctx->isFileContext())) {
6915 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
6919 CodeCompleter->loadExternal());
6923 Results.getCompletionContext(), Results.data(),
6934 Context.setIsUsingDeclaration(
true);
6936 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6937 CodeCompleter->getCodeCompletionTUInfo(), Context,
6938 &ResultBuilder::IsNestedNameSpecifier);
6939 Results.EnterNewScope();
6942 if (!S->isClassScope())
6947 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6949 CodeCompleter->includeGlobals(),
6950 CodeCompleter->loadExternal());
6951 Results.ExitScope();
6954 Results.getCompletionContext(), Results.data(),
6964 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6965 CodeCompleter->getCodeCompletionTUInfo(),
6967 &ResultBuilder::IsNamespaceOrAlias);
6968 Results.EnterNewScope();
6969 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6971 CodeCompleter->includeGlobals(),
6972 CodeCompleter->loadExternal());
6973 Results.ExitScope();
6975 Results.getCompletionContext(), Results.data(),
6984 if (!S->getParent())
6987 bool SuppressedGlobalResults =
6988 Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
6990 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6991 CodeCompleter->getCodeCompletionTUInfo(),
6992 SuppressedGlobalResults
6995 &ResultBuilder::IsNamespace);
6997 if (Ctx && Ctx->isFileContext() && !SuppressedGlobalResults) {
7002 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
7004 NS(Ctx->decls_begin()),
7005 NSEnd(Ctx->decls_end());
7007 OrigToLatest[NS->getFirstDecl()] = *NS;
7011 Results.EnterNewScope();
7012 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
7013 NS = OrigToLatest.begin(),
7014 NSEnd = OrigToLatest.end();
7020 Results.ExitScope();
7024 Results.getCompletionContext(), Results.data(),
7033 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7034 CodeCompleter->getCodeCompletionTUInfo(),
7036 &ResultBuilder::IsNamespaceOrAlias);
7037 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7039 CodeCompleter->includeGlobals(),
7040 CodeCompleter->loadExternal());
7042 Results.getCompletionContext(), Results.data(),
7051 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7052 CodeCompleter->getCodeCompletionTUInfo(),
7054 &ResultBuilder::IsType);
7055 Results.EnterNewScope();
7059#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
7060 if (OO_##Name != OO_Conditional) \
7061 Results.AddResult(Result(Spelling));
7062#include "clang/Basic/OperatorKinds.def"
7065 Results.allowNestedNameSpecifiers();
7066 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7068 CodeCompleter->includeGlobals(),
7069 CodeCompleter->loadExternal());
7073 Results.ExitScope();
7076 Results.getCompletionContext(), Results.data(),
7087 auto *Constructor = dyn_cast<CXXConstructorDecl>(ConstructorD);
7091 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7092 CodeCompleter->getCodeCompletionTUInfo(),
7094 Results.EnterNewScope();
7099 for (
unsigned I = 0,
E = Initializers.size(); I !=
E; ++I) {
7100 if (Initializers[I]->isBaseInitializer())
7101 InitializedBases.insert(getASTContext().getCanonicalType(
7102 QualType(Initializers[I]->getBaseClass(), 0)));
7104 InitializedFields.insert(
7105 cast<FieldDecl>(Initializers[I]->getAnyMember()));
7110 bool SawLastInitializer = Initializers.empty();
7113 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
7115 Results.getCodeCompletionTUInfo());
7116 Builder.AddTypedTextChunk(Name);
7118 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND))
7120 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
7122 FunTemplDecl->getTemplatedDecl(), Builder);
7124 return Builder.TakeString();
7126 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
7129 Results.getCodeCompletionTUInfo());
7130 Builder.AddTypedTextChunk(Name);
7132 Builder.AddPlaceholderChunk(
Type);
7136 Builder.TakeString(), ND,
7138 if (isa<FieldDecl>(ND))
7140 return Results.AddResult(CCR);
7143 Builder.TakeString(),
7147 const char *Name,
const FieldDecl *FD) {
7149 return AddDefaultCtorInit(Name,
7150 FD ? Results.getAllocator().CopyString(
7151 FD->getType().getAsString(Policy))
7155 if (Ctors.begin() == Ctors.end())
7156 return AddDefaultCtorInit(Name, Name, RD);
7160 Results.AddResult(CCR);
7164 const char *BaseName =
7165 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
7166 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
7171 auto AddField = [&](
const FieldDecl *FD) {
7172 const char *FieldName =
7173 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
7174 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
7180 for (
const auto &
Base : ClassDecl->
bases()) {
7181 if (!InitializedBases
7182 .insert(getASTContext().getCanonicalType(
Base.getType()))
7184 SawLastInitializer =
7185 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7186 getASTContext().hasSameUnqualifiedType(
7187 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7192 SawLastInitializer =
false;
7196 for (
const auto &
Base : ClassDecl->
vbases()) {
7197 if (!InitializedBases
7198 .insert(getASTContext().getCanonicalType(
Base.getType()))
7200 SawLastInitializer =
7201 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7202 getASTContext().hasSameUnqualifiedType(
7203 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7208 SawLastInitializer =
false;
7212 for (
auto *Field : ClassDecl->
fields()) {
7213 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
7215 SawLastInitializer = !Initializers.empty() &&
7216 Initializers.back()->isAnyMemberInitializer() &&
7217 Initializers.back()->getAnyMember() == Field;
7221 if (!Field->getDeclName())
7225 SawLastInitializer =
false;
7227 Results.ExitScope();
7230 Results.getCompletionContext(), Results.data(),
7245 bool AfterAmpersand) {
7246 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7247 CodeCompleter->getCodeCompletionTUInfo(),
7249 Results.EnterNewScope();
7253 bool IncludedThis =
false;
7256 IncludedThis =
true;
7265 for (
const auto *
D : S->decls()) {
7266 const auto *Var = dyn_cast<VarDecl>(
D);
7267 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
7270 if (Known.insert(Var->getIdentifier()).second)
7280 Results.ExitScope();
7283 Results.getCompletionContext(), Results.data(),
7290 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7291 CodeCompleter->getCodeCompletionTUInfo(),
7293 auto ShouldAddDefault = [&
D,
this]() {
7294 if (!
D.isFunctionDeclarator())
7296 auto &
Id =
D.getName();
7302 D.getFunctionTypeInfo().NumParams <= 1)
7305 auto Op =
Id.OperatorFunctionId.Operator;
7308 if (Op == OverloadedOperatorKind::OO_Equal)
7310 if (getLangOpts().CPlusPlus20 &&
7311 (Op == OverloadedOperatorKind::OO_EqualEqual ||
7312 Op == OverloadedOperatorKind::OO_ExclaimEqual ||
7313 Op == OverloadedOperatorKind::OO_Less ||
7314 Op == OverloadedOperatorKind::OO_LessEqual ||
7315 Op == OverloadedOperatorKind::OO_Greater ||
7316 Op == OverloadedOperatorKind::OO_GreaterEqual ||
7317 Op == OverloadedOperatorKind::OO_Spaceship))
7323 Results.EnterNewScope();
7324 if (ShouldAddDefault())
7325 Results.AddResult(
"default");
7328 Results.AddResult(
"delete");
7329 Results.ExitScope();
7331 Results.getCompletionContext(), Results.data(),
7337#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
7340 ResultBuilder &Results,
bool NeedAt) {
7346 Results.getCodeCompletionTUInfo());
7347 if (LangOpts.ObjC) {
7351 Builder.AddPlaceholderChunk(
"property");
7352 Results.AddResult(
Result(Builder.TakeString()));
7357 Builder.AddPlaceholderChunk(
"property");
7358 Results.AddResult(
Result(Builder.TakeString()));
7363 ResultBuilder &Results,
bool NeedAt) {
7369 if (LangOpts.ObjC) {
7384 Results.getCodeCompletionTUInfo());
7389 Builder.AddPlaceholderChunk(
"name");
7390 Results.AddResult(
Result(Builder.TakeString()));
7392 if (Results.includeCodePatterns()) {
7398 Builder.AddPlaceholderChunk(
"class");
7399 Results.AddResult(
Result(Builder.TakeString()));
7404 Builder.AddPlaceholderChunk(
"protocol");
7405 Results.AddResult(
Result(Builder.TakeString()));
7410 Builder.AddPlaceholderChunk(
"class");
7411 Results.AddResult(
Result(Builder.TakeString()));
7415 Builder.AddTypedTextChunk(
7418 Builder.AddPlaceholderChunk(
"alias");
7420 Builder.AddPlaceholderChunk(
"class");
7421 Results.AddResult(
Result(Builder.TakeString()));
7423 if (Results.getSema().getLangOpts().Modules) {
7427 Builder.AddPlaceholderChunk(
"module");
7428 Results.AddResult(
Result(Builder.TakeString()));
7433 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7434 CodeCompleter->getCodeCompletionTUInfo(),
7436 Results.EnterNewScope();
7443 Results.ExitScope();
7445 Results.getCompletionContext(), Results.data(),
7452 Results.getCodeCompletionTUInfo());
7455 const char *EncodeType =
"char[]";
7456 if (Results.getSema().getLangOpts().CPlusPlus ||
7457 Results.getSema().getLangOpts().ConstStrings)
7458 EncodeType =
"const char[]";
7459 Builder.AddResultTypeChunk(EncodeType);
7462 Builder.AddPlaceholderChunk(
"type-name");
7464 Results.AddResult(
Result(Builder.TakeString()));
7467 Builder.AddResultTypeChunk(
"Protocol *");
7470 Builder.AddPlaceholderChunk(
"protocol-name");
7472 Results.AddResult(
Result(Builder.TakeString()));
7475 Builder.AddResultTypeChunk(
"SEL");
7478 Builder.AddPlaceholderChunk(
"selector");
7480 Results.AddResult(
Result(Builder.TakeString()));
7483 Builder.AddResultTypeChunk(
"NSString *");
7485 Builder.AddPlaceholderChunk(
"string");
7486 Builder.AddTextChunk(
"\"");
7487 Results.AddResult(
Result(Builder.TakeString()));
7490 Builder.AddResultTypeChunk(
"NSArray *");
7492 Builder.AddPlaceholderChunk(
"objects, ...");
7494 Results.AddResult(
Result(Builder.TakeString()));
7497 Builder.AddResultTypeChunk(
"NSDictionary *");
7499 Builder.AddPlaceholderChunk(
"key");
7502 Builder.AddPlaceholderChunk(
"object, ...");
7504 Results.AddResult(
Result(Builder.TakeString()));
7507 Builder.AddResultTypeChunk(
"id");
7509 Builder.AddPlaceholderChunk(
"expression");
7511 Results.AddResult(
Result(Builder.TakeString()));
7517 Results.getCodeCompletionTUInfo());
7519 if (Results.includeCodePatterns()) {
7524 Builder.AddPlaceholderChunk(
"statements");
7526 Builder.AddTextChunk(
"@catch");
7528 Builder.AddPlaceholderChunk(
"parameter");
7531 Builder.AddPlaceholderChunk(
"statements");
7533 Builder.AddTextChunk(
"@finally");
7535 Builder.AddPlaceholderChunk(
"statements");
7537 Results.AddResult(
Result(Builder.TakeString()));
7543 Builder.AddPlaceholderChunk(
"expression");
7544 Results.AddResult(
Result(Builder.TakeString()));
7546 if (Results.includeCodePatterns()) {
7551 Builder.AddPlaceholderChunk(
"expression");
7554 Builder.AddPlaceholderChunk(
"statements");
7556 Results.AddResult(
Result(Builder.TakeString()));
7561 ResultBuilder &Results,
bool NeedAt) {
7571 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7572 CodeCompleter->getCodeCompletionTUInfo(),
7574 Results.EnterNewScope();
7576 Results.ExitScope();
7578 Results.getCompletionContext(), Results.data(),
7583 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7584 CodeCompleter->getCodeCompletionTUInfo(),
7586 Results.EnterNewScope();
7589 Results.ExitScope();
7591 Results.getCompletionContext(), Results.data(),
7596 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7597 CodeCompleter->getCodeCompletionTUInfo(),
7599 Results.EnterNewScope();
7601 Results.ExitScope();
7603 Results.getCompletionContext(), Results.data(),
7611 if (Attributes & NewFlag)
7614 Attributes |= NewFlag;
7622 unsigned AssignCopyRetMask =
7628 if (AssignCopyRetMask &&
7647 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7648 CodeCompleter->getCodeCompletionTUInfo(),
7650 Results.EnterNewScope();
7687 Results.getCodeCompletionTUInfo());
7696 Results.getCodeCompletionTUInfo());
7709 Results.ExitScope();
7711 Results.getCompletionContext(), Results.data(),
7725 bool AllowSameLength =
true) {
7726 unsigned NumSelIdents = SelIdents.size();
7739 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
7742 for (
unsigned I = 0; I != NumSelIdents; ++I)
7752 bool AllowSameLength =
true) {
7786 ResultBuilder &Results,
bool InOriginalClass =
true,
7787 bool IsRootClass =
false) {
7791 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
7795 if (M->isInstanceMethod() == WantInstanceMethods ||
7796 (IsRootClass && !WantInstanceMethods)) {
7802 if (!Selectors.insert(M->getSelector()).second)
7805 Result R =
Result(M, Results.getBasePriority(M),
nullptr);
7806 R.StartParameter = SelIdents.size();
7807 R.AllParametersAreInformative = (WantKind !=
MK_Any);
7808 if (!InOriginalClass)
7810 Results.MaybeAddResult(R, CurContext);
7815 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
7816 if (Protocol->hasDefinition()) {
7818 Protocol->getReferencedProtocols();
7820 E = Protocols.
end();
7822 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7823 Selectors, AllowSameLength, Results,
false, IsRootClass);
7832 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7833 Selectors, AllowSameLength, Results,
false, IsRootClass);
7837 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
7838 CurContext, Selectors, AllowSameLength, Results,
7839 InOriginalClass, IsRootClass);
7843 CatDecl->getReferencedProtocols();
7845 E = Protocols.
end();
7847 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7848 Selectors, AllowSameLength, Results,
false, IsRootClass);
7852 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7853 Selectors, AllowSameLength, Results, InOriginalClass,
7861 SelIdents, CurContext, Selectors, AllowSameLength, Results,
7866 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7867 Selectors, AllowSameLength, Results, InOriginalClass,
7874 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7877 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7885 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7886 CodeCompleter->getCodeCompletionTUInfo(),
7888 Results.EnterNewScope();
7894 Results.ExitScope();
7896 Results.getCompletionContext(), Results.data(),
7903 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7906 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7914 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7915 CodeCompleter->getCodeCompletionTUInfo(),
7917 Results.EnterNewScope();
7924 Results.ExitScope();
7926 Results.getCompletionContext(), Results.data(),
7932 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7933 CodeCompleter->getCodeCompletionTUInfo(),
7935 Results.EnterNewScope();
7938 bool AddedInOut =
false;
7941 Results.AddResult(
"in");
7942 Results.AddResult(
"inout");
7947 Results.AddResult(
"out");
7949 Results.AddResult(
"inout");
7954 Results.AddResult(
"bycopy");
7955 Results.AddResult(
"byref");
7956 Results.AddResult(
"oneway");
7959 Results.AddResult(
"nonnull");
7960 Results.AddResult(
"nullable");
7961 Results.AddResult(
"null_unspecified");
7971 Results.getCodeCompletionTUInfo(),
7973 Builder.AddTypedTextChunk(
"IBAction");
7975 Builder.AddPlaceholderChunk(
"selector");
7978 Builder.AddTextChunk(
"id");
7980 Builder.AddTextChunk(
"sender");
7991 Results.ExitScope();
7994 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
7995 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7997 CodeCompleter->includeGlobals(),
7998 CodeCompleter->loadExternal());
8000 if (CodeCompleter->includeMacros())
8004 Results.getCompletionContext(), Results.data(),
8013 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(
E);
8031 switch (Msg->getReceiverKind()) {
8035 IFace = ObjType->getInterface();
8039 QualType T = Msg->getInstanceReceiver()->getType();
8041 IFace = Ptr->getInterfaceDecl();
8055 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
8056 .Case(
"retain", IFace)
8057 .Case(
"strong", IFace)
8058 .Case(
"autorelease", IFace)
8059 .Case(
"copy", IFace)
8060 .Case(
"copyWithZone", IFace)
8061 .Case(
"mutableCopy", IFace)
8062 .Case(
"mutableCopyWithZone", IFace)
8063 .Case(
"awakeFromCoder", IFace)
8064 .Case(
"replacementObjectFromCoder", IFace)
8065 .Case(
"class", IFace)
8066 .Case(
"classForCoder", IFace)
8067 .Case(
"superclass", Super)
8070 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
8072 .Case(
"alloc", IFace)
8073 .Case(
"allocWithZone", IFace)
8074 .Case(
"class", IFace)
8075 .Case(
"superclass", Super)
8098 ResultBuilder &Results) {
8109 while ((
Class =
Class->getSuperClass()) && !SuperMethod) {
8116 for (
const auto *Cat :
Class->known_categories()) {
8117 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
8135 CurP != CurPEnd; ++CurP, ++SuperP) {
8138 (*SuperP)->getType()))
8142 if (!(*CurP)->getIdentifier())
8148 Results.getCodeCompletionTUInfo());
8152 Results.getCompletionContext().getBaseType(), Builder);
8155 if (NeedSuperKeyword) {
8156 Builder.AddTypedTextChunk(
"super");
8162 if (NeedSuperKeyword)
8163 Builder.AddTextChunk(
8166 Builder.AddTypedTextChunk(
8170 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
8171 if (I > SelIdents.size())
8174 if (I < SelIdents.size())
8175 Builder.AddInformativeChunk(
8177 else if (NeedSuperKeyword || I > SelIdents.size()) {
8178 Builder.AddTextChunk(
8180 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8181 (*CurP)->getIdentifier()->getName()));
8183 Builder.AddTypedTextChunk(
8185 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8186 (*CurP)->getIdentifier()->getName()));
8198 ResultBuilder Results(
8199 SemaRef, CodeCompleter->getAllocator(),
8200 CodeCompleter->getCodeCompletionTUInfo(),
8203 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
8204 : &ResultBuilder::IsObjCMessageReceiver);
8206 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
8207 Results.EnterNewScope();
8209 CodeCompleter->includeGlobals(),
8210 CodeCompleter->loadExternal());
8216 if (Iface->getSuperClass()) {
8217 Results.AddResult(
Result(
"super"));
8225 Results.ExitScope();
8227 if (CodeCompleter->includeMacros())
8230 Results.getCompletionContext(), Results.data(),
8240 CDecl = CurMethod->getClassInterface();
8249 if (CurMethod->isInstanceMethod()) {
8253 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
8254 AtArgumentExpression, CDecl);
8264 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
8266 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
8268 getASTContext().getTypeDeclType(TD)->getAs<ObjCObjectType>())
8269 CDecl = Iface->getInterface();
8270 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
8282 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
8283 SelIdents, AtArgumentExpression);
8292 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
8293 AtArgumentExpression,
8300 unsigned NumSelIdents) {
8302 ASTContext &Context = Results.getSema().Context;
8306 Result *ResultsData = Results.data();
8307 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
8308 Result &R = ResultsData[I];
8309 if (R.Kind == Result::RK_Declaration &&
8310 isa<ObjCMethodDecl>(R.Declaration)) {
8311 if (R.Priority <= BestPriority) {
8312 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
8313 if (NumSelIdents <= Method->param_size()) {
8315 Method->
parameters()[NumSelIdents - 1]->getType();
8316 if (R.Priority < BestPriority || PreferredType.
isNull()) {
8317 BestPriority = R.Priority;
8318 PreferredType = MyPreferredType;
8328 return PreferredType;
8334 bool AtArgumentExpression,
bool IsSuper,
8335 ResultBuilder &Results) {
8350 Results.EnterNewScope();
8357 Results.Ignore(SuperMethod);
8363 Results.setPreferredSelector(CurMethod->getSelector());
8368 Selectors, AtArgumentExpression, Results);
8375 for (uint32_t I = 0,
8386 for (SemaObjC::GlobalMethodPool::iterator
8391 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8395 Result R(MethList->getMethod(),
8396 Results.getBasePriority(MethList->getMethod()),
nullptr);
8397 R.StartParameter = SelIdents.size();
8398 R.AllParametersAreInformative =
false;
8399 Results.MaybeAddResult(R, SemaRef.
CurContext);
8404 Results.ExitScope();
8409 bool AtArgumentExpression,
bool IsSuper) {
8413 ResultBuilder Results(
8414 SemaRef, CodeCompleter->getAllocator(),
8415 CodeCompleter->getCodeCompletionTUInfo(),
8420 AtArgumentExpression, IsSuper, Results);
8427 if (AtArgumentExpression) {
8430 if (PreferredType.
isNull())
8431 CodeCompleteOrdinaryName(S, PCC_Expression);
8433 CodeCompleteExpression(S, PreferredType);
8438 Results.getCompletionContext(), Results.data(),
8448 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
8456 RecExpr = Conv.
get();
8470 return CodeCompleteObjCClassMessage(
8472 AtArgumentExpression, Super);
8477 }
else if (RecExpr && getLangOpts().CPlusPlus) {
8480 RecExpr = Conv.
get();
8481 ReceiverType = RecExpr->
getType();
8486 ResultBuilder Results(
8487 SemaRef, CodeCompleter->getAllocator(),
8488 CodeCompleter->getCodeCompletionTUInfo(),
8490 ReceiverType, SelIdents));
8492 Results.EnterNewScope();
8499 Results.Ignore(SuperMethod);
8505 Results.setPreferredSelector(CurMethod->getSelector());
8518 Selectors, AtArgumentExpression, Results);
8525 for (
auto *I : QualID->quals())
8527 AtArgumentExpression, Results);
8534 SemaRef.
CurContext, Selectors, AtArgumentExpression,
8538 for (
auto *I : IFacePtr->quals())
8540 AtArgumentExpression, Results);
8550 for (uint32_t I = 0,
8561 for (SemaObjC::GlobalMethodPool::iterator
8566 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8570 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
8573 Result R(MethList->getMethod(),
8574 Results.getBasePriority(MethList->getMethod()),
nullptr);
8575 R.StartParameter = SelIdents.size();
8576 R.AllParametersAreInformative =
false;
8577 Results.MaybeAddResult(R, SemaRef.
CurContext);
8581 Results.ExitScope();
8588 if (AtArgumentExpression) {
8591 if (PreferredType.
isNull())
8592 CodeCompleteOrdinaryName(S, PCC_Expression);
8594 CodeCompleteExpression(S, PreferredType);
8599 Results.getCompletionContext(), Results.data(),
8606 Data.ObjCCollection =
true;
8612 Data.IgnoreDecls.push_back(*I);
8616 CodeCompleteExpression(S,
Data);
8624 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
8634 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8635 CodeCompleter->getCodeCompletionTUInfo(),
8637 Results.EnterNewScope();
8638 for (SemaObjC::GlobalMethodPool::iterator
8648 Results.getCodeCompletionTUInfo());
8650 Builder.AddTypedTextChunk(
8652 Results.AddResult(Builder.TakeString());
8656 std::string Accumulator;
8657 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
8658 if (I == SelIdents.size()) {
8659 if (!Accumulator.empty()) {
8660 Builder.AddInformativeChunk(
8661 Builder.getAllocator().CopyString(Accumulator));
8662 Accumulator.clear();
8669 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
8670 Results.AddResult(Builder.TakeString());
8672 Results.ExitScope();
8675 Results.getCompletionContext(), Results.data(),
8682 bool OnlyForwardDeclarations,
8683 ResultBuilder &Results) {
8686 for (
const auto *
D : Ctx->decls()) {
8688 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(
D))
8689 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
8691 Result(Proto, Results.getBasePriority(Proto),
nullptr), CurContext,
8698 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8699 CodeCompleter->getCodeCompletionTUInfo(),
8702 if (CodeCompleter->includeGlobals()) {
8703 Results.EnterNewScope();
8711 Results.Ignore(Protocol);
8717 Results.ExitScope();
8721 Results.getCompletionContext(), Results.data(),
8726 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8727 CodeCompleter->getCodeCompletionTUInfo(),
8730 if (CodeCompleter->includeGlobals()) {
8731 Results.EnterNewScope();
8737 Results.ExitScope();
8741 Results.getCompletionContext(), Results.data(),
8748 bool OnlyForwardDeclarations,
8749 bool OnlyUnimplemented,
8750 ResultBuilder &Results) {
8753 for (
const auto *
D : Ctx->decls()) {
8755 if (
const auto *
Class = dyn_cast<ObjCInterfaceDecl>(
D))
8756 if ((!OnlyForwardDeclarations || !
Class->hasDefinition()) &&
8757 (!OnlyUnimplemented || !
Class->getImplementation()))
8765 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8766 CodeCompleter->getCodeCompletionTUInfo(),
8768 Results.EnterNewScope();
8770 if (CodeCompleter->includeGlobals()) {
8776 Results.ExitScope();
8779 Results.getCompletionContext(), Results.data(),
8784 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8785 CodeCompleter->getCodeCompletionTUInfo(),
8787 Results.EnterNewScope();
8789 if (CodeCompleter->includeGlobals()) {
8795 Results.ExitScope();
8798 Results.getCompletionContext(), Results.data(),
8804 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8805 CodeCompleter->getCodeCompletionTUInfo(),
8807 Results.EnterNewScope();
8812 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
8813 Results.Ignore(CurClass);
8815 if (CodeCompleter->includeGlobals()) {
8821 Results.ExitScope();
8824 Results.getCompletionContext(), Results.data(),
8829 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8830 CodeCompleter->getCodeCompletionTUInfo(),
8832 Results.EnterNewScope();
8834 if (CodeCompleter->includeGlobals()) {
8840 Results.ExitScope();
8843 Results.getCompletionContext(), Results.data(),
8851 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8852 CodeCompleter->getCodeCompletionTUInfo(),
8861 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
8862 for (
const auto *Cat :
Class->visible_categories())
8863 CategoryNames.insert(Cat->getIdentifier());
8867 Results.EnterNewScope();
8869 for (
const auto *
D : TU->
decls())
8870 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(
D))
8871 if (CategoryNames.insert(
Category->getIdentifier()).second)
8875 Results.ExitScope();
8878 Results.getCompletionContext(), Results.data(),
8893 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
8895 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8896 CodeCompleter->getCodeCompletionTUInfo(),
8903 Results.EnterNewScope();
8904 bool IgnoreImplemented =
true;
8906 for (
const auto *Cat :
Class->visible_categories()) {
8907 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
8908 CategoryNames.insert(Cat->getIdentifier()).second)
8909 Results.AddResult(
Result(Cat, Results.getBasePriority(Cat),
nullptr),
8914 IgnoreImplemented =
false;
8916 Results.ExitScope();
8919 Results.getCompletionContext(), Results.data(),
8925 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8926 CodeCompleter->getCodeCompletionTUInfo(), CCContext);
8930 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8931 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8932 !isa<ObjCCategoryImplDecl>(Container)))
8937 for (
const auto *
D : Container->decls())
8938 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(
D))
8939 Results.Ignore(PropertyImpl->getPropertyDecl());
8943 Results.EnterNewScope();
8945 dyn_cast<ObjCImplementationDecl>(Container))
8948 AddedProperties, Results);
8951 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
8953 AddedProperties, Results);
8954 Results.ExitScope();
8957 Results.getCompletionContext(), Results.data(),
8964 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8965 CodeCompleter->getCodeCompletionTUInfo(),
8970 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8971 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8972 !isa<ObjCCategoryImplDecl>(Container)))
8978 dyn_cast<ObjCImplementationDecl>(Container))
8979 Class = ClassImpl->getClassInterface();
8981 Class = cast<ObjCCategoryImplDecl>(Container)
8983 ->getClassInterface();
8986 QualType PropertyType = getASTContext().getObjCIdType();
8991 Property->getType().getNonReferenceType().getUnqualifiedType();
8994 Results.setPreferredType(PropertyType);
8999 Results.EnterNewScope();
9000 bool SawSimilarlyNamedIvar =
false;
9001 std::string NameWithPrefix;
9002 NameWithPrefix +=
'_';
9003 NameWithPrefix += PropertyName->getName();
9004 std::string NameWithSuffix = PropertyName->getName().str();
9005 NameWithSuffix +=
'_';
9008 Ivar = Ivar->getNextIvar()) {
9009 Results.AddResult(
Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
9014 if ((PropertyName == Ivar->getIdentifier() ||
9015 NameWithPrefix == Ivar->getName() ||
9016 NameWithSuffix == Ivar->getName())) {
9017 SawSimilarlyNamedIvar =
true;
9021 if (Results.size() &&
9022 Results.data()[Results.size() - 1].Kind ==
9024 Results.data()[Results.size() - 1].Declaration == Ivar)
9025 Results.data()[Results.size() - 1].Priority--;
9030 if (!SawSimilarlyNamedIvar) {
9041 PropertyType, getASTContext(), Policy, Allocator));
9042 Builder.AddTypedTextChunk(Allocator.CopyString(NameWithPrefix));
9047 Results.ExitScope();
9050 Results.getCompletionContext(), Results.data(),
9057 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
9066 std::optional<bool> WantInstanceMethods,
9069 bool InOriginalClass =
true) {
9072 if (!IFace->hasDefinition())
9075 IFace = IFace->getDefinition();
9079 IFace->getReferencedProtocols();
9081 E = Protocols.
end();
9084 KnownMethods, InOriginalClass);
9087 for (
auto *Cat : IFace->visible_categories()) {
9089 KnownMethods,
false);
9093 if (IFace->getSuperClass())
9095 WantInstanceMethods, ReturnType, KnownMethods,
9102 Category->getReferencedProtocols();
9104 E = Protocols.
end();
9107 KnownMethods, InOriginalClass);
9110 if (InOriginalClass &&
Category->getClassInterface())
9112 WantInstanceMethods, ReturnType, KnownMethods,
9118 if (!Protocol->hasDefinition())
9120 Protocol = Protocol->getDefinition();
9121 Container = Protocol;
9125 Protocol->getReferencedProtocols();
9127 E = Protocols.
end();
9130 KnownMethods,
false);
9136 for (
auto *M : Container->methods()) {
9137 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
9138 if (!ReturnType.
isNull() &&
9142 KnownMethods[M->getSelector()] =
9143 KnownMethodsMap::mapped_type(M, InOriginalClass);
9157 Builder.AddTextChunk(Builder.getAllocator().CopyString(Quals));
9158 Builder.AddTextChunk(
9169 if (
Class->getIdentifier() &&
Class->getIdentifier()->getName() == Name)
9178 bool IsInstanceMethod,
9181 ResultBuilder &Results) {
9183 if (!PropName || PropName->
getLength() == 0)
9201 const char *CopiedKey;
9204 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
9206 operator const char *() {
9210 return CopiedKey = Allocator.CopyString(Key);
9212 } Key(Allocator, PropName->
getName());
9215 std::string UpperKey = std::string(PropName->
getName());
9216 if (!UpperKey.empty())
9219 bool ReturnTypeMatchesProperty =
9223 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
9226 if (IsInstanceMethod &&
9228 ReturnTypeMatchesProperty && !
Property->getGetterMethodDecl()) {
9233 Builder.AddTypedTextChunk(Key);
9240 if (IsInstanceMethod &&
9241 ((!ReturnType.
isNull() &&
9244 Property->getType()->isBooleanType())))) {
9245 std::string SelectorName = (Twine(
"is") + UpperKey).str();
9249 if (ReturnType.
isNull()) {
9251 Builder.AddTextChunk(
"BOOL");
9255 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9262 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
9263 !
Property->getSetterMethodDecl()) {
9264 std::string SelectorName = (Twine(
"set") + UpperKey).str();
9266 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9267 if (ReturnType.
isNull()) {
9269 Builder.AddTextChunk(
"void");
9273 Builder.AddTypedTextChunk(
9274 Allocator.CopyString(SelectorId->
getName() +
":"));
9277 Builder.AddTextChunk(Key);
9288 if (
const auto *ObjCPointer =
9313 if (IsInstanceMethod &&
9315 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
9319 if (ReturnType.
isNull()) {
9321 Builder.AddTextChunk(
"NSUInteger");
9325 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9327 Result(Builder.TakeString(),
9328 std::min(IndexedGetterPriority, UnorderedGetterPriority),
9335 if (IsInstanceMethod &&
9337 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
9339 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9340 if (ReturnType.
isNull()) {
9342 Builder.AddTextChunk(
"id");
9346 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9348 Builder.AddTextChunk(
"NSUInteger");
9350 Builder.AddTextChunk(
"index");
9351 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9357 if (IsInstanceMethod &&
9364 std::string SelectorName = (Twine(
Property->getName()) +
"AtIndexes").str();
9366 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9367 if (ReturnType.
isNull()) {
9369 Builder.AddTextChunk(
"NSArray *");
9373 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9375 Builder.AddTextChunk(
"NSIndexSet *");
9377 Builder.AddTextChunk(
"indexes");
9378 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9384 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9385 std::string SelectorName = (Twine(
"get") + UpperKey).str();
9389 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9390 if (ReturnType.
isNull()) {
9392 Builder.AddTextChunk(
"void");
9396 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9398 Builder.AddPlaceholderChunk(
"object-type");
9399 Builder.AddTextChunk(
" **");
9401 Builder.AddTextChunk(
"buffer");
9403 Builder.AddTypedTextChunk(
"range:");
9405 Builder.AddTextChunk(
"NSRange");
9407 Builder.AddTextChunk(
"inRange");
9408 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9416 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9417 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
9421 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9422 if (ReturnType.
isNull()) {
9424 Builder.AddTextChunk(
"void");
9428 Builder.AddTypedTextChunk(
"insertObject:");
9430 Builder.AddPlaceholderChunk(
"object-type");
9431 Builder.AddTextChunk(
" *");
9433 Builder.AddTextChunk(
"object");
9435 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9437 Builder.AddPlaceholderChunk(
"NSUInteger");
9439 Builder.AddTextChunk(
"index");
9440 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9446 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9447 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
9451 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9452 if (ReturnType.
isNull()) {
9454 Builder.AddTextChunk(
"void");
9458 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9460 Builder.AddTextChunk(
"NSArray *");
9462 Builder.AddTextChunk(
"array");
9464 Builder.AddTypedTextChunk(
"atIndexes:");
9466 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9468 Builder.AddTextChunk(
"indexes");
9469 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9475 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9476 std::string SelectorName =
9477 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
9479 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9480 if (ReturnType.
isNull()) {
9482 Builder.AddTextChunk(
"void");
9486 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9488 Builder.AddTextChunk(
"NSUInteger");
9490 Builder.AddTextChunk(
"index");
9491 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9497 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9498 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
9500 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9501 if (ReturnType.
isNull()) {
9503 Builder.AddTextChunk(
"void");
9507 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9509 Builder.AddTextChunk(
"NSIndexSet *");
9511 Builder.AddTextChunk(
"indexes");
9512 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9518 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9519 std::string SelectorName =
9520 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
9524 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9525 if (ReturnType.
isNull()) {
9527 Builder.AddTextChunk(
"void");
9531 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9533 Builder.AddPlaceholderChunk(
"NSUInteger");
9535 Builder.AddTextChunk(
"index");
9537 Builder.AddTypedTextChunk(
"withObject:");
9539 Builder.AddTextChunk(
"id");
9541 Builder.AddTextChunk(
"object");
9542 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9548 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9549 std::string SelectorName1 =
9550 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
9551 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
9555 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9556 if (ReturnType.
isNull()) {
9558 Builder.AddTextChunk(
"void");
9562 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName1 +
":"));
9564 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9566 Builder.AddTextChunk(
"indexes");
9568 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName2 +
":"));
9570 Builder.AddTextChunk(
"NSArray *");
9572 Builder.AddTextChunk(
"array");
9573 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9580 if (IsInstanceMethod &&
9586 ->
getName() ==
"NSEnumerator"))) {
9587 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
9591 if (ReturnType.
isNull()) {
9593 Builder.AddTextChunk(
"NSEnumerator *");
9597 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9598 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9604 if (IsInstanceMethod &&
9606 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
9608 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9609 if (ReturnType.
isNull()) {
9611 Builder.AddPlaceholderChunk(
"object-type");
9612 Builder.AddTextChunk(
" *");
9616 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9618 if (ReturnType.
isNull()) {
9619 Builder.AddPlaceholderChunk(
"object-type");
9620 Builder.AddTextChunk(
" *");
9623 ReturnType, Context, Policy, Builder.getAllocator()));
9626 Builder.AddTextChunk(
"object");
9627 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9634 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9635 std::string SelectorName =
9636 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
9638 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9639 if (ReturnType.
isNull()) {
9641 Builder.AddTextChunk(
"void");
9645 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9647 Builder.AddPlaceholderChunk(
"object-type");
9648 Builder.AddTextChunk(
" *");
9650 Builder.AddTextChunk(
"object");
9651 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9657 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9658 std::string SelectorName = (Twine(
"add") + UpperKey).str();
9660 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9661 if (ReturnType.
isNull()) {
9663 Builder.AddTextChunk(
"void");
9667 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9669 Builder.AddTextChunk(
"NSSet *");
9671 Builder.AddTextChunk(
"objects");
9672 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9678 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9679 std::string SelectorName =
9680 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
9682 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9683 if (ReturnType.
isNull()) {
9685 Builder.AddTextChunk(
"void");
9689 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9691 Builder.AddPlaceholderChunk(
"object-type");
9692 Builder.AddTextChunk(
" *");
9694 Builder.AddTextChunk(
"object");
9695 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9701 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9702 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
9704 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9705 if (ReturnType.
isNull()) {
9707 Builder.AddTextChunk(
"void");
9711 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9713 Builder.AddTextChunk(
"NSSet *");
9715 Builder.AddTextChunk(
"objects");
9716 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9722 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9723 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
9725 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9726 if (ReturnType.
isNull()) {
9728 Builder.AddTextChunk(
"void");
9732 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9734 Builder.AddTextChunk(
"NSSet *");
9736 Builder.AddTextChunk(
"objects");
9737 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9744 if (!IsInstanceMethod &&
9751 std::string SelectorName =
9752 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
9756 if (ReturnType.
isNull()) {
9758 Builder.AddTextChunk(
"NSSet<NSString *> *");
9762 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9769 if (!IsInstanceMethod &&
9772 std::string SelectorName =
9773 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
9777 if (ReturnType.
isNull()) {
9779 Builder.AddTextChunk(
"BOOL");
9783 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9791 Scope *S, std::optional<bool> IsInstanceMethod,
ParsedType ReturnTy) {
9796 Decl *IDecl =
nullptr;
9803 bool IsInImplementation =
false;
9804 if (
Decl *
D = IDecl) {
9806 SearchDecl = Impl->getClassInterface();
9807 IsInImplementation =
true;
9809 dyn_cast<ObjCCategoryImplDecl>(
D)) {
9810 SearchDecl = CatImpl->getCategoryDecl();
9811 IsInImplementation =
true;
9813 SearchDecl = dyn_cast<ObjCContainerDecl>(
D);
9816 if (!SearchDecl && S) {
9818 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
9834 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9835 CodeCompleter->getCodeCompletionTUInfo(),
9837 Results.EnterNewScope();
9839 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9840 MEnd = KnownMethods.end();
9844 Results.getCodeCompletionTUInfo());
9847 if (!IsInstanceMethod) {
9854 if (ReturnType.
isNull()) {
9865 Builder.AddTypedTextChunk(
9872 P != PEnd; (
void)++
P, ++I) {
9875 Builder.AddTypedTextChunk(
9879 Builder.AddTypedTextChunk(
9887 ParamType = (*P)->getType();
9889 ParamType = (*P)->getOriginalType();
9894 Context, Policy, Builder);
9897 Builder.AddTextChunk(
9898 Builder.getAllocator().CopyString(
Id->getName()));
9905 Builder.AddTextChunk(
"...");
9908 if (IsInImplementation && Results.includeCodePatterns()) {
9915 Builder.AddTextChunk(
"return");
9917 Builder.AddPlaceholderChunk(
"expression");
9920 Builder.AddPlaceholderChunk(
"statements");
9928 if (!M->second.getInt())
9930 Results.AddResult(std::move(R));
9937 Containers.push_back(SearchDecl);
9940 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9941 MEnd = KnownMethods.end();
9943 KnownSelectors.insert(M->first);
9948 IFace =
Category->getClassInterface();
9953 if (IsInstanceMethod) {
9954 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
9955 for (
auto *
P : Containers[I]->instance_properties())
9957 KnownSelectors, Results);
9961 Results.ExitScope();
9964 Results.getCompletionContext(), Results.data(),
9969 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
9974 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
9986 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9987 CodeCompleter->getCodeCompletionTUInfo(),
9991 Results.setPreferredType(
9994 Results.EnterNewScope();
9995 for (SemaObjC::GlobalMethodPool::iterator
9999 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
10000 : &M->second.second;
10001 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
10005 if (AtParameterName) {
10007 unsigned NumSelIdents = SelIdents.size();
10008 if (NumSelIdents &&
10009 NumSelIdents <= MethList->getMethod()->param_size()) {
10011 MethList->getMethod()->parameters()[NumSelIdents - 1];
10014 Results.getCodeCompletionTUInfo());
10015 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
10017 Results.AddResult(Builder.TakeString());
10024 Result R(MethList->getMethod(),
10025 Results.getBasePriority(MethList->getMethod()),
nullptr);
10026 R.StartParameter = SelIdents.size();
10027 R.AllParametersAreInformative =
false;
10028 R.DeclaringEntity =
true;
10029 Results.MaybeAddResult(R, SemaRef.
CurContext);
10033 Results.ExitScope();
10035 if (!AtParameterName && !SelIdents.empty() &&
10036 SelIdents.front()->getName().starts_with(
"init")) {
10037 for (
const auto &M : SemaRef.
PP.
macros()) {
10038 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
10040 Results.EnterNewScope();
10042 Results.getCodeCompletionTUInfo());
10043 Builder.AddTypedTextChunk(
10044 Builder.getAllocator().CopyString(M.first->getName()));
10047 Results.ExitScope();
10052 Results.getCompletionContext(), Results.data(),
10057 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10058 CodeCompleter->getCodeCompletionTUInfo(),
10060 Results.EnterNewScope();
10064 Results.getCodeCompletionTUInfo());
10065 Builder.AddTypedTextChunk(
"if");
10067 Builder.AddPlaceholderChunk(
"condition");
10068 Results.AddResult(Builder.TakeString());
10071 Builder.AddTypedTextChunk(
"ifdef");
10073 Builder.AddPlaceholderChunk(
"macro");
10074 Results.AddResult(Builder.TakeString());
10077 Builder.AddTypedTextChunk(
"ifndef");
10079 Builder.AddPlaceholderChunk(
"macro");
10080 Results.AddResult(Builder.TakeString());
10082 if (InConditional) {
10084 Builder.AddTypedTextChunk(
"elif");
10086 Builder.AddPlaceholderChunk(
"condition");
10087 Results.AddResult(Builder.TakeString());
10090 Builder.AddTypedTextChunk(
"elifdef");
10092 Builder.AddPlaceholderChunk(
"macro");
10093 Results.AddResult(Builder.TakeString());
10096 Builder.AddTypedTextChunk(
"elifndef");
10098 Builder.AddPlaceholderChunk(
"macro");
10099 Results.AddResult(Builder.TakeString());
10102 Builder.AddTypedTextChunk(
"else");
10103 Results.AddResult(Builder.TakeString());
10106 Builder.AddTypedTextChunk(
"endif");
10107 Results.AddResult(Builder.TakeString());
10111 Builder.AddTypedTextChunk(
"include");
10113 Builder.AddTextChunk(
"\"");
10114 Builder.AddPlaceholderChunk(
"header");
10115 Builder.AddTextChunk(
"\"");
10116 Results.AddResult(Builder.TakeString());
10119 Builder.AddTypedTextChunk(
"include");
10121 Builder.AddTextChunk(
"<");
10122 Builder.AddPlaceholderChunk(
"header");
10123 Builder.AddTextChunk(
">");
10124 Results.AddResult(Builder.TakeString());
10127 Builder.AddTypedTextChunk(
"define");
10129 Builder.AddPlaceholderChunk(
"macro");
10130 Results.AddResult(Builder.TakeString());
10133 Builder.AddTypedTextChunk(
"define");
10135 Builder.AddPlaceholderChunk(
"macro");
10137 Builder.AddPlaceholderChunk(
"args");
10139 Results.AddResult(Builder.TakeString());
10142 Builder.AddTypedTextChunk(
"undef");
10144 Builder.AddPlaceholderChunk(
"macro");
10145 Results.AddResult(Builder.TakeString());
10148 Builder.AddTypedTextChunk(
"line");
10150 Builder.AddPlaceholderChunk(
"number");
10151 Results.AddResult(Builder.TakeString());
10154 Builder.AddTypedTextChunk(
"line");
10156 Builder.AddPlaceholderChunk(
"number");
10158 Builder.AddTextChunk(
"\"");
10159 Builder.AddPlaceholderChunk(
"filename");
10160 Builder.AddTextChunk(
"\"");
10161 Results.AddResult(Builder.TakeString());
10164 Builder.AddTypedTextChunk(
"error");
10166 Builder.AddPlaceholderChunk(
"message");
10167 Results.AddResult(Builder.TakeString());
10170 Builder.AddTypedTextChunk(
"pragma");
10172 Builder.AddPlaceholderChunk(
"arguments");
10173 Results.AddResult(Builder.TakeString());
10175 if (getLangOpts().
ObjC) {
10177 Builder.AddTypedTextChunk(
"import");
10179 Builder.AddTextChunk(
"\"");
10180 Builder.AddPlaceholderChunk(
"header");
10181 Builder.AddTextChunk(
"\"");
10182 Results.AddResult(Builder.TakeString());
10185 Builder.AddTypedTextChunk(
"import");
10187 Builder.AddTextChunk(
"<");
10188 Builder.AddPlaceholderChunk(
"header");
10189 Builder.AddTextChunk(
">");
10190 Results.AddResult(Builder.TakeString());
10194 Builder.AddTypedTextChunk(
"include_next");
10196 Builder.AddTextChunk(
"\"");
10197 Builder.AddPlaceholderChunk(
"header");
10198 Builder.AddTextChunk(
"\"");
10199 Results.AddResult(Builder.TakeString());
10202 Builder.AddTypedTextChunk(
"include_next");
10204 Builder.AddTextChunk(
"<");
10205 Builder.AddPlaceholderChunk(
"header");
10206 Builder.AddTextChunk(
">");
10207 Results.AddResult(Builder.TakeString());
10210 Builder.AddTypedTextChunk(
"warning");
10212 Builder.AddPlaceholderChunk(
"message");
10213 Results.AddResult(Builder.TakeString());
10220 Results.ExitScope();
10223 Results.getCompletionContext(), Results.data(),
10229 CodeCompleteOrdinaryName(S, S->getFnParent()
10235 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10236 CodeCompleter->getCodeCompletionTUInfo(),
10239 if (!IsDefinition && CodeCompleter->includeMacros()) {
10242 Results.getCodeCompletionTUInfo());
10243 Results.EnterNewScope();
10247 Builder.AddTypedTextChunk(
10248 Builder.getAllocator().CopyString(M->first->getName()));
10252 Results.ExitScope();
10253 }
else if (IsDefinition) {
10258 Results.getCompletionContext(), Results.data(),
10263 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10264 CodeCompleter->getCodeCompletionTUInfo(),
10267 if (CodeCompleter->includeMacros())
10271 Results.EnterNewScope();
10273 Results.getCodeCompletionTUInfo());
10274 Builder.AddTypedTextChunk(
"defined");
10277 Builder.AddPlaceholderChunk(
"macro");
10279 Results.AddResult(Builder.TakeString());
10280 Results.ExitScope();
10283 Results.getCompletionContext(), Results.data(),
10303 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
10306 llvm::sys::path::native(NativeRelDir);
10307 llvm::vfs::FileSystem &FS =
10310 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10311 CodeCompleter->getCodeCompletionTUInfo(),
10313 llvm::DenseSet<StringRef> SeenResults;
10316 auto AddCompletion = [&](StringRef
Filename,
bool IsDirectory) {
10319 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
10320 auto R = SeenResults.insert(TypedChunk);
10322 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
10323 *R.first = InternedTyped;
10325 CodeCompleter->getCodeCompletionTUInfo());
10326 Builder.AddTypedTextChunk(InternedTyped);
10334 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
10338 if (!NativeRelDir.empty()) {
10342 auto Begin = llvm::sys::path::begin(NativeRelDir);
10343 auto End = llvm::sys::path::end(NativeRelDir);
10345 llvm::sys::path::append(Dir, *
Begin +
".framework",
"Headers");
10346 llvm::sys::path::append(Dir, ++
Begin, End);
10348 llvm::sys::path::append(Dir, NativeRelDir);
10352 const StringRef &Dirname = llvm::sys::path::filename(Dir);
10353 const bool isQt = Dirname.starts_with(
"Qt") || Dirname ==
"ActiveQt";
10354 const bool ExtensionlessHeaders =
10355 IsSystem || isQt || Dir.ends_with(
".framework/Headers");
10356 std::error_code EC;
10357 unsigned Count = 0;
10358 for (
auto It = FS.dir_begin(Dir, EC);
10359 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
10360 if (++Count == 2500)
10362 StringRef
Filename = llvm::sys::path::filename(It->path());
10367 llvm::sys::fs::file_type
Type = It->type();
10368 if (
Type == llvm::sys::fs::file_type::symlink_file) {
10369 if (
auto FileStatus = FS.status(It->path()))
10370 Type = FileStatus->getType();
10373 case llvm::sys::fs::file_type::directory_file:
10377 NativeRelDir.empty() && !
Filename.consume_back(
".framework"))
10382 case llvm::sys::fs::file_type::regular_file: {
10384 const bool IsHeader =
Filename.ends_with_insensitive(
".h") ||
10385 Filename.ends_with_insensitive(
".hh") ||
10386 Filename.ends_with_insensitive(
".hpp") ||
10387 Filename.ends_with_insensitive(
".hxx") ||
10388 Filename.ends_with_insensitive(
".inc") ||
10389 (ExtensionlessHeaders && !
Filename.contains(
'.'));
10404 switch (IncludeDir.getLookupType()) {
10409 AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
10413 AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
10423 using llvm::make_range;
10427 AddFilesFromIncludeDir(CurFile->getDir().getName(),
false,
10429 for (
const auto &
D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
10430 AddFilesFromDirLookup(
D,
false);
10432 for (
const auto &
D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
10433 AddFilesFromDirLookup(
D,
false);
10434 for (
const auto &
D : make_range(S.system_dir_begin(), S.system_dir_end()))
10435 AddFilesFromDirLookup(
D,
true);
10438 Results.getCompletionContext(), Results.data(),
10449 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10450 CodeCompleter->getCodeCompletionTUInfo(),
10452 Results.EnterNewScope();
10453 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
10457 Twine(Platform) +
"ApplicationExtension")));
10459 Results.ExitScope();
10461 Results.getCompletionContext(), Results.data(),
10468 ResultBuilder Builder(SemaRef, Allocator, CCTUInfo,
10470 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
10471 CodeCompletionDeclConsumer Consumer(
10472 Builder, getASTContext().getTranslationUnitDecl());
10475 !CodeCompleter || CodeCompleter->loadExternal());
10478 if (!CodeCompleter || CodeCompleter->includeMacros())
10480 !CodeCompleter || CodeCompleter->loadExternal(),
true);
10483 Results.insert(Results.end(), Builder.data(),
10484 Builder.data() + Builder.size());
10489 :
SemaBase(S), CodeCompleter(CompletionConsumer),
10490 Resolver(S.getASTContext()) {}
This file provides AST data structures related to concepts.
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
enum clang::sema::@1727::IndirectLocalPathEntry::EntryKind Kind
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
llvm::MachO::Target Target
llvm::MachO::Record Record
Defines the clang::MacroInfo and clang::MacroDirective classes.
Defines an enumeration for C++ overloaded operators.
Defines the clang::Preprocessor interface.
static std::string getName(const CallEvent &Call)
static AccessResult IsAccessible(Sema &S, const EffectiveContext &EC, AccessTarget &Entity)
Determines whether the accessed entity is accessible.
static QualType getPreferredArgumentTypeForMessageSend(ResultBuilder &Results, unsigned NumSelIdents)
Given a set of code-completion results for the argument of a message send, determine the preferred ty...
static void printOverrideString(const CodeCompletionString &CCS, std::string &BeforeName, std::string &NameAndSignature)
static bool isConstructor(const Decl *ND)
static void findTypeLocationForBlockDecl(const TypeSourceInfo *TSInfo, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlock=false)
Tries to find the most appropriate type location for an Objective-C block placeholder.
static void AddQualifierToCompletionString(CodeCompletionBuilder &Result, NestedNameSpecifier *Qualifier, bool QualifierIsInformative, ASTContext &Context, const PrintingPolicy &Policy)
Add a qualifier to the given code-completion string, if the provided nested-name-specifier is non-NUL...
static bool isObjCReceiverType(ASTContext &C, QualType T)
static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, bool LoadExternal, bool IncludeUndefined, bool TargetTypeIsPointer=false)
static std::string formatTemplateParameterPlaceholder(const NamedDecl *Param, bool &Optional, const PrintingPolicy &Policy)
static std::string formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlockName=false, bool SuppressBlock=false, std::optional< ArrayRef< QualType > > ObjCSubsts=std::nullopt)
Returns a placeholder string that corresponds to an Objective-C block declaration.
static void AddTemplateParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const TemplateDecl *Template, CodeCompletionBuilder &Result, unsigned MaxParameters=0, unsigned Start=0, bool InDefaultArg=false)
Add template parameter chunks to the given code completion string.
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
static FunctionProtoTypeLoc GetPrototypeLoc(Expr *Fn)
static void AddFunctionParameterChunks(Preprocessor &PP, const PrintingPolicy &Policy, const FunctionDecl *Function, CodeCompletionBuilder &Result, unsigned Start=0, bool InOptional=false)
Add function parameter chunks to the given code completion string.
llvm::SmallPtrSet< const IdentifierInfo *, 16 > AddedPropertiesSet
The set of properties that have already been added, referenced by property name.
static bool argMatchesTemplateParams(const ParsedTemplateArgument &Arg, unsigned Index, const TemplateParameterList &Params)
static void setInBaseClass(ResultBuilder::Result &R)
static void AddObjCMethods(ObjCContainerDecl *Container, bool WantInstanceMethods, ObjCMethodKind WantKind, ArrayRef< const IdentifierInfo * > SelIdents, DeclContext *CurContext, VisitedSelectorSet &Selectors, bool AllowSameLength, ResultBuilder &Results, bool InOriginalClass=true, bool IsRootClass=false)
Add all of the Objective-C methods in the given Objective-C container to the set of results.
static bool shouldIgnoreDueToReservedName(const NamedDecl *ND, Sema &SemaRef)
static RecordDecl * getAsRecordDecl(QualType BaseType)
static CodeCompletionString * createTemplateSignatureString(const TemplateDecl *TD, CodeCompletionBuilder &Builder, unsigned CurrentArg, const PrintingPolicy &Policy)
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
static void AddStorageSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
static const NamedDecl * extractFunctorCallOperator(const NamedDecl *ND)
static void AddFunctionSpecifiers(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
static QualType ProduceSignatureHelp(Sema &SemaRef, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, SourceLocation OpenParLoc, bool Braced)
static std::string FormatFunctionParameter(const PrintingPolicy &Policy, const DeclaratorDecl *Param, bool SuppressName=false, bool SuppressBlock=false, std::optional< ArrayRef< QualType > > ObjCSubsts=std::nullopt)
static void AddOverrideResults(ResultBuilder &Results, const CodeCompletionContext &CCContext, CodeCompletionBuilder &Builder)
static std::string formatObjCParamQualifiers(unsigned ObjCQuals, QualType &Type)
llvm::SmallPtrSet< Selector, 16 > VisitedSelectorSet
A set of selectors, which is used to avoid introducing multiple completions with the same selector in...
static void AddOverloadAggregateChunks(const RecordDecl *RD, const PrintingPolicy &Policy, CodeCompletionBuilder &Result, unsigned CurrentArg)
static void AddTypedefResult(ResultBuilder &Results)
static void AddPrettyFunctionResults(const LangOptions &LangOpts, ResultBuilder &Results)
static QualType getDesignatedType(QualType BaseType, const Designation &Desig)
static void AddObjCPassingTypeChunk(QualType Type, unsigned ObjCDeclQuals, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder)
Add the parenthesized return or parameter type chunk to a code completion string.
static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property, bool IsInstanceMethod, QualType ReturnType, ASTContext &Context, VisitedSelectorSet &KnownSelectors, ResultBuilder &Results)
Add code completions for Objective-C Key-Value Coding (KVC) and Key-Value Observing (KVO).
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt)
static bool ObjCPropertyFlagConflicts(unsigned Attributes, unsigned NewFlag)
Determine whether the addition of the given flag to an Objective-C property's attributes will cause a...
static void AddEnumerators(ResultBuilder &Results, ASTContext &Context, EnumDecl *Enum, DeclContext *CurContext, const CoveredEnumerators &Enumerators)
llvm::DenseMap< Selector, llvm::PointerIntPair< ObjCMethodDecl *, 1, bool > > KnownMethodsMap
static const FunctionProtoType * TryDeconstructFunctionLike(QualType T)
Try to find a corresponding FunctionProtoType for function-like types (e.g.
static DeclContext::lookup_result getConstructors(ASTContext &Context, const CXXRecordDecl *Record)
static void AddResultTypeChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, QualType BaseType, CodeCompletionBuilder &Result)
If the given declaration has an associated type, add it as a result type chunk.
static void AddObjCVisibilityResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
static void addThisCompletion(Sema &S, ResultBuilder &Results)
Add a completion for "this", if we're in a member function.
static void AddObjCImplementationResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
static ObjCMethodDecl * AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword, ArrayRef< const IdentifierInfo * > SelIdents, ResultBuilder &Results)
static void AddRecordMembersCompletionResults(Sema &SemaRef, ResultBuilder &Results, Scope *S, QualType BaseType, ExprValueKind BaseKind, RecordDecl *RD, std::optional< FixItHint > AccessOpFixIt)
static void AddObjCBlockCall(ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionBuilder &Builder, const NamedDecl *BD, const FunctionTypeLoc &BlockLoc, const FunctionProtoTypeLoc &BlockProtoLoc)
Adds a block invocation code completion result for the given block declaration BD.
static void AddLambdaCompletion(ResultBuilder &Results, llvm::ArrayRef< QualType > Parameters, const LangOptions &LangOpts)
Adds a pattern completion for a lambda expression with the specified parameter types and placeholders...
static void AddTypeSpecifierResults(const LangOptions &LangOpts, ResultBuilder &Results)
Add type specifiers for the current language as keyword results.
static std::optional< unsigned > getNextAggregateIndexAfterDesignatedInit(const ResultCandidate &Aggregate, ArrayRef< Expr * > Args)
static std::string GetDefaultValueString(const ParmVarDecl *Param, const SourceManager &SM, const LangOptions &LangOpts)
static CodeCompletionContext mapCodeCompletionContext(Sema &S, SemaCodeCompletion::ParserCompletionContext PCC)
static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, bool OnlyUnimplemented, ResultBuilder &Results)
Add all of the Objective-C interface declarations that we find in the given (translation unit) contex...
static NestedNameSpecifier * getRequiredQualification(ASTContext &Context, const DeclContext *CurContext, const DeclContext *TargetContext)
Compute the qualification required to get from the current context (CurContext) to the target context...
static OverloadCompare compareOverloads(const CXXMethodDecl &Candidate, const CXXMethodDecl &Incumbent, const Qualifiers &ObjectQuals, ExprValueKind ObjectKind, const ASTContext &Ctx)
static void FindImplementableMethods(ASTContext &Context, ObjCContainerDecl *Container, std::optional< bool > WantInstanceMethods, QualType ReturnType, KnownMethodsMap &KnownMethods, bool InOriginalClass=true)
Find all of the methods that reside in the given container (and its superclasses, protocols,...
static bool anyNullArguments(ArrayRef< Expr * > Args)
static const char * noUnderscoreAttrScope(llvm::StringRef Scope)
static void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function)
static void MaybeAddSentinel(Preprocessor &PP, const NamedDecl *FunctionOrMethod, CodeCompletionBuilder &Result)
static void AddOverloadParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const FunctionDecl *Function, const FunctionProtoType *Prototype, FunctionProtoTypeLoc PrototypeLoc, CodeCompletionBuilder &Result, unsigned CurrentArg, unsigned Start=0, bool InOptional=false)
Add function overload parameter chunks to the given code completion string.
static void AddObjCProperties(const CodeCompletionContext &CCContext, ObjCContainerDecl *Container, bool AllowCategories, bool AllowNullaryMethods, DeclContext *CurContext, AddedPropertiesSet &AddedProperties, ResultBuilder &Results, bool IsBaseExprStatement=false, bool IsClassProperty=false, bool InOriginalClass=true)
static void HandleCodeCompleteResults(Sema *S, CodeCompleteConsumer *CodeCompleter, const CodeCompletionContext &Context, CodeCompletionResult *Results, unsigned NumResults)
static void AddTypeQualifierResults(DeclSpec &DS, ResultBuilder &Results, const LangOptions &LangOpts)
static void MaybeAddOverrideCalls(Sema &S, DeclContext *InContext, ResultBuilder &Results)
If we're in a C++ virtual member function, add completion results that invoke the functions we overri...
static ObjCContainerDecl * getContainerDef(ObjCContainerDecl *Container)
Retrieve the container definition, if any?
static const char * underscoreAttrScope(llvm::StringRef Scope)
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method, ObjCMethodKind WantKind, ArrayRef< const IdentifierInfo * > SelIdents, bool AllowSameLength=true)
static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt)
static bool WantTypesInContext(SemaCodeCompletion::ParserCompletionContext CCC, const LangOptions &LangOpts)
CodeCompleteConsumer::OverloadCandidate ResultCandidate
static std::string templateResultType(const TemplateDecl *TD, const PrintingPolicy &Policy)
static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, CodeCompletionBuilder &Result)
Add the name of the given declaration.
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper, ResultBuilder &Results)
static const char * GetCompletionTypeString(QualType T, ASTContext &Context, const PrintingPolicy &Policy, CodeCompletionAllocator &Allocator)
Retrieve the string representation of the given type as a string that has the appropriate lifetime fo...
static bool InheritsFromClassNamed(ObjCInterfaceDecl *Class, StringRef Name)
Determine whether the given class is or inherits from a class by the given name.
#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword)
Macro that optionally prepends an "@" to the string literal passed in via Keyword,...
static bool isAcceptableObjCSelector(Selector Sel, ObjCMethodKind WantKind, ArrayRef< const IdentifierInfo * > SelIdents, bool AllowSameLength=true)
static QualType getPreferredTypeOfBinaryRHS(Sema &S, Expr *LHS, tok::TokenKind Op)
static void AddOrdinaryNameResults(SemaCodeCompletion::ParserCompletionContext CCC, Scope *S, Sema &SemaRef, ResultBuilder &Results)
Add language constructs that show up for "ordinary" names.
static QualType getPreferredTypeOfUnaryArg(Sema &S, QualType ContextType, tok::TokenKind Op)
Get preferred type for an argument of an unary expression.
static void AddUsingAliasResult(CodeCompletionBuilder &Builder, ResultBuilder &Results)
static ObjCInterfaceDecl * GetAssumedMessageSendExprType(Expr *E)
When we have an expression with type "id", we may assume that it has some more-specific class type ba...
ObjCMethodKind
Describes the kind of Objective-C method that we want to find via code completion.
@ MK_OneArgSelector
One-argument selector.
@ MK_ZeroArgSelector
Zero-argument (unary) selector.
@ MK_Any
Any kind of method, provided it means other specified criteria.
static void mergeCandidatesWithResults(Sema &SemaRef, SmallVectorImpl< ResultCandidate > &Results, OverloadCandidateSet &CandidateSet, SourceLocation Loc, size_t ArgSize)
static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext, bool OnlyForwardDeclarations, ResultBuilder &Results)
Add all of the protocol declarations that we find in the given (translation unit) context.
static void AddStaticAssertResult(CodeCompletionBuilder &Builder, ResultBuilder &Results, const LangOptions &LangOpts)
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
static bool isNamespaceScope(Scope *S)
Determine whether this scope denotes a namespace.
static PrintingPolicy getCompletionPrintingPolicy(const ASTContext &Context, const Preprocessor &PP)
This file declares facilities that support code completion.
This file declares semantic analysis for Objective-C.
static TemplateDecl * getDescribedTemplate(Decl *Templated)
Defines various enumerations that describe declaration and type specifiers.
enum clang::format::@1338::AnnotatingParser::Context::@353 ContextType
C Language Family Type Representation.
pointer(const DeclIndexPair &Value)
const DeclIndexPair * operator->() const
pointer operator->() const
reference operator*() const
std::ptrdiff_t difference_type
friend bool operator!=(const iterator &X, const iterator &Y)
iterator(const NamedDecl *SingleDecl, unsigned Index)
std::input_iterator_tag iterator_category
iterator(const DeclIndexPair *Iterator)
friend bool operator==(const iterator &X, const iterator &Y)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
DeclarationNameTable DeclarationNames
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
SelectorTable & Selectors
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getElementType() const
Syntax
The style used to specify an attribute.
Type source information for an attributed type.
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Wrapper for source info for block pointers.
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Represents a static or instance method of a struct/union/class.
overridden_method_range overridden_methods() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Qualifiers getMethodQualifiers() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
CXXRecordDecl * getDefinition() const
base_class_range vbases()
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CaseStmt - Represent a case statement.
Represents a character-granular source range.
static CharSourceRange getTokenRange(SourceRange R)
Declaration of a class template.
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments, bool Braced) const
Create a new code-completion string that describes the function signature of this overload candidate.
const FunctionType * getFunctionType() const
Retrieve the function type of the entity, regardless of how the function is stored.
const TemplateDecl * getTemplate() const
CandidateKind getKind() const
Determine the kind of overload candidate.
const RecordDecl * getAggregate() const
Retrieve the aggregate type being initialized.
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
const FunctionProtoTypeLoc getFunctionProtoTypeLoc() const
Retrieve the function ProtoTypeLoc candidate.
@ CK_Aggregate
The candidate is aggregate initialization of a record type.
@ CK_Template
The candidate is a template, template arguments are being completed.
unsigned getNumParams() const
Get the number of parameters in this signature.
Abstract interface for a consumer of code-completion information.
bool includeGlobals() const
Whether to include global (top-level) declaration results.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results.
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced)
An allocator used specifically for the purpose of code completion.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
A builder class used to construct new code-completion strings.
CodeCompletionString * TakeString()
Take the resulting completion string.
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
void AddTextChunk(const char *Text)
Add a new text chunk.
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
The context in which code completion occurred, so that the code-completion consumer can process the r...
Kind getKind() const
Retrieve the kind of code-completion context.
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
@ CCC_TypeQualifiers
Code completion within a type-qualifier list.
@ CCC_ObjCMessageReceiver
Code completion occurred where an Objective-C message receiver is expected.
@ CCC_PreprocessorExpression
Code completion occurred within a preprocessor expression.
@ CCC_ObjCCategoryName
Code completion where an Objective-C category name is expected.
@ CCC_ObjCIvarList
Code completion occurred within the instance variable list of an Objective-C interface,...
@ CCC_Statement
Code completion occurred where a statement (or declaration) is expected in a function,...
@ CCC_Type
Code completion occurred where a type name is expected.
@ CCC_ArrowMemberAccess
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
@ CCC_ClassStructUnion
Code completion occurred within a class, struct, or union.
@ CCC_ObjCInterface
Code completion occurred within an Objective-C interface, protocol, or category interface.
@ CCC_ObjCPropertyAccess
Code completion occurred on the right-hand side of an Objective-C property access expression.
@ CCC_Expression
Code completion occurred where an expression is expected.
@ CCC_SelectorName
Code completion for a selector, as in an @selector expression.
@ CCC_TopLevelOrExpression
Code completion at a top level, i.e.
@ CCC_EnumTag
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
@ CCC_UnionTag
Code completion occurred after the "union" keyword, to indicate a union name.
@ CCC_ParenthesizedExpression
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
@ CCC_TopLevel
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope.
@ CCC_ClassOrStructTag
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name.
@ CCC_ObjCClassMessage
Code completion where an Objective-C class message is expected.
@ CCC_ObjCImplementation
Code completion occurred within an Objective-C implementation or category implementation.
@ CCC_IncludedFile
Code completion inside the filename part of a #include directive.
@ CCC_ObjCInstanceMessage
Code completion where an Objective-C instance message is expected.
@ CCC_SymbolOrNewName
Code completion occurred where both a new name and an existing symbol is permissible.
@ CCC_Recovery
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
@ CCC_ObjCProtocolName
Code completion occurred where a protocol name is expected.
@ CCC_NewName
Code completion occurred where a new name is expected.
@ CCC_MacroNameUse
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
@ CCC_Symbol
Code completion occurred where an existing name(such as type, function or variable) is expected.
@ CCC_Attribute
Code completion of an attribute name.
@ CCC_Other
An unspecified code-completion context.
@ CCC_DotMemberAccess
Code completion occurred on the right-hand side of a member access expression using the dot operator.
@ CCC_MacroName
Code completion occurred where an macro is being defined.
@ CCC_Namespace
Code completion occurred where a namespace or namespace alias is expected.
@ CCC_PreprocessorDirective
Code completion occurred where a preprocessor directive is expected.
@ CCC_NaturalLanguage
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
@ CCC_ObjCInterfaceName
Code completion where the name of an Objective-C class is expected.
@ CCC_ObjCClassForwardDecl
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
void setPreferredType(QualType T)
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
void setIsUsingDeclaration(bool V)
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
Captures a result of code completion.
bool DeclaringEntity
Whether we're completing a declaration of the given entity, rather than a use of that entity.
ResultKind Kind
The kind of result stored here.
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling.
CXAvailabilityKind Availability
The availability of this result.
NestedNameSpecifier * Qualifier
If the result should have a nested-name-specifier, this is it.
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program.
bool QualifierIsInformative
Whether this result was found via lookup into a base class.
const NamedDecl * Declaration
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to.
CodeCompletionString * createCodeCompletionStringForDecl(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
CodeCompletionString * CreateCodeCompletionStringForMacro(Preprocessor &PP, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Creates a new code-completion string for the macro result.
unsigned StartParameter
Specifies which parameter (of a function, Objective-C method, macro, etc.) we should start with when ...
bool InBaseClass
Whether this is a class member from base class.
unsigned Priority
The priority of this particular code-completion result.
bool StartsNestedNameSpecifier
Whether this declaration is the beginning of a nested-name-specifier and, therefore,...
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert.
bool FunctionCanBeCall
When completing a function, whether it can be a call.
bool AllParametersAreInformative
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative".
CodeCompletionString * createCodeCompletionStringForOverride(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
const IdentifierInfo * Macro
When Kind == RK_Macro, the identifier that refers to a macro.
@ RK_Pattern
Refers to a precomputed pattern.
@ RK_Declaration
Refers to a declaration.
@ RK_Macro
Refers to a macro.
@ RK_Keyword
Refers to a keyword or symbol.
A "string" used to describe how code completion can be performed for an entity.
@ CK_Optional
A code completion string that is entirely optional.
@ CK_CurrentParameter
A piece of text that describes the parameter that corresponds to the code-completion location within ...
@ CK_Comma
A comma separator (',').
@ CK_Placeholder
A string that acts as a placeholder for, e.g., a function call argument.
@ CK_LeftParen
A left parenthesis ('(').
@ CK_HorizontalSpace
Horizontal whitespace (' ').
@ CK_RightAngle
A right angle bracket ('>').
@ CK_LeftBracket
A left bracket ('[').
@ CK_RightParen
A right parenthesis (')').
@ CK_RightBrace
A right brace ('}').
@ CK_VerticalSpace
Vertical whitespace ('\n' or '\r\n', depending on the platform).
@ CK_SemiColon
A semicolon (';').
@ CK_TypedText
The piece of text that the user is expected to type to match the code-completion string,...
@ CK_RightBracket
A right bracket (']').
@ CK_LeftBrace
A left brace ('{').
@ CK_LeftAngle
A left angle bracket ('<').
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
const TypeClass * getTypePtr() const
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isRequiresExprBody() const
bool isFileContext() const
bool isObjCContainer() const
ASTContext & getParentASTContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Captures information about "declaration specifiers".
static const TST TST_typename
TST getTypeSpecType() const
static const TST TST_interface
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static const TST TST_union
TSC getTypeSpecComplex() const
ParsedType getRepAsType() const
static const TST TST_enum
static const TST TST_class
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
bool isTypeAltiVecVector() const
TypeSpecifierSign getTypeSpecSign() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
@ FOK_Undeclared
A friend of a previously-undeclared entity.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
unsigned getIdentifierNamespace() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
@ IDNS_Member
Members, declared with object declarations within tag definitions.
@ IDNS_ObjCProtocol
Objective C @protocol.
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
@ IDNS_LocalExtern
This declaration is a function-local extern declaration of a variable or function.
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
TranslationUnitDecl * getTranslationUnitDecl()
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
uintptr_t getAsOpaqueInteger() const
Get the representation of this declaration name as an opaque integer.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Represents a ValueDecl that came out of a declarator.
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
Represents a qualified type name for which the type name is dependent.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
const IdentifierInfo * getIdentifier() const
Retrieve the identifier that terminates this type name.
A qualified reference to a name whose declaration cannot yet be resolved.
Designation - Represent a full designation, which is a sequence of designators.
const Designator & getDesignator(unsigned Idx) const
unsigned getNumDesignators() const
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
Recursive AST visitor that supports extension via dynamic dispatch.
virtual bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Recursively visit a C++ nested-name-specifier with location information.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
virtual Selector GetExternalSelector(uint32_t ID)
Resolve a selector ID into a selector.
virtual uint32_t GetNumExternalSelectors()
Returns the number of selectors known to the external AST source.
Represents a member of a struct/union/class.
llvm::vfs::FileSystem & getVirtualFileSystem() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
Represents a function declaration or definition.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
param_iterator param_end()
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
size_t param_size() const
Represents a prototype with parameter type info, e.g.
bool isVariadic() const
Whether this function prototype is variadic.
Declaration of a template function.
Wrapper for source info for functions.
unsigned getNumParams() const
ParmVarDecl * getParam(unsigned i) const
TypeLoc getReturnLoc() const
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getReturnType() const
const QualType getPointeeType(QualType T) const
std::vector< const NamedDecl * > resolveDependentNameType(const DependentNameType *DNT) const
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef deuglifiedName() const
If the identifier is an "uglified" reserved name, return a cleaned form.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const TypeClass * getTypePtr() const
The injected class name of a C++ class template or class template partial specialization.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Represents the results of name lookup.
const UnresolvedSetImpl & asUnresolvedSet() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
Encapsulates the data about a macro definition (e.g.
bool isC99Varargs() const
bool isFunctionLike() const
param_iterator param_begin() const
IdentifierInfo *const * param_iterator
Parameters - The list of parameters for a function-like macro.
param_iterator param_end() const
bool isUsedForHeaderGuard() const
Determine whether this macro was used for a header guard.
virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, Module::NameVisibilityKind Visibility, bool IsInclusionDirective)=0
Attempt to load the given module.
Describes a module or submodule.
@ AllVisible
All of the names in this module are visible.
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.
A C++ nested-name-specifier augmented with source location information.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
ObjCCategoryDecl - Represents a category declaration.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCContainerDecl - Represents a container for method declarations.
Captures information about "declaration specifiers" specific to Objective-C.
ObjCPropertyAttribute::Kind getPropertyAttributes() const
ObjCDeclQualifier getObjCDeclQualifier() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
bool hasDefinition() const
Determine whether this class has been defined.
protocol_range protocols() const
known_categories_range known_categories() const
ObjCImplementationDecl * getImplementation() const
visible_categories_range visible_categories() const
ObjCInterfaceDecl * getSuperClass() const
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCList - This is a simple template class used to hold various lists of decls etc,...
@ SuperInstance
The receiver is the instance of the superclass object.
@ Instance
The receiver is an object instance.
@ SuperClass
The receiver is a superclass.
@ Class
The receiver is a class.
ObjCMethodDecl - Represents an instance or class method declaration.
ObjCDeclQualifier getObjCDeclQualifier() const
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
param_const_iterator param_end() const
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
param_const_iterator param_begin() const
const ParmVarDecl *const * param_const_iterator
Selector getSelector() const
bool isInstanceMethod() const
QualType getReturnType() const
ParmVarDecl *const * param_iterator
ObjCInterfaceDecl * getClassInterface()
Represents a pointer to an Objective C object.
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface.
Represents a class type in Objective C.
Represents one property declaration in an Objective-C interface.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
Selector getGetterName() const
Represents an Objective-C protocol declaration.
void * getAsOpaquePtr() const
static OpaquePtr make(QualType P)
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Normal
Normal lookup.
CandidateSetKind getKind() const
Represents a parameter to a function.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
Represents the parsed form of a C++ template argument.
KindType getKind() const
Determine what kind of template argument we have.
@ Type
A template type parameter, stored as a type.
@ Template
A template template argument, stored as a template name.
@ NonType
A non-type template parameter, stored as an expression.
Wrapper for source info for pointers.
PointerType - C99 6.7.5.1 - Pointer Declarators.
void enterFunctionArgument(SourceLocation Tok, llvm::function_ref< QualType()> ComputeType)
Computing a type for the function argument may require running overloading, so we postpone its comput...
void enterCondition(Sema &S, SourceLocation Tok)
void enterTypeCast(SourceLocation Tok, QualType CastType)
Handles all type casts, including C-style cast, C++ casts, etc.
void enterMemAccess(Sema &S, SourceLocation Tok, Expr *Base)
void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS)
void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind, SourceLocation OpLoc)
void enterReturn(Sema &S, SourceLocation Tok)
void enterDesignatedInitializer(SourceLocation Tok, QualType BaseType, const Designation &D)
Handles e.g. BaseType{ .D = Tok...
void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op)
void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc)
void enterVariableInit(SourceLocation Tok, Decl *D)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
OptionalFileEntryRef getFileEntry() const
getFileEntry - Return the FileEntry corresponding to this FileID.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with this preprocessor.
macro_iterator macro_end(bool IncludeExternalMacros=true) const
SourceManager & getSourceManager() const
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
bool isMacroDefined(StringRef Id)
MacroMap::const_iterator macro_iterator
llvm::iterator_range< macro_iterator > macros(bool IncludeExternalMacros=true) const
PreprocessorLexer * getCurrentFileLexer() const
Return the current file lexer being lexed from.
HeaderSearch & getHeaderSearchInfo() const
const LangOptions & getLangOpts() const
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
Wrapper of type source information for a type with non-trivial direct qualifiers.
The collection of all-type qualifiers we support.
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
Scope - A scope is a transient data structure that is used while parsing the program.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
@ ClassScope
The scope of a struct/union/class definition.
@ DeclScope
This is a scope that can contain a declaration.
This table allows us to fully hide how we implement multi-keyword caching.
Selector getNullarySelector(const IdentifierInfo *ID)
Selector getSelector(unsigned NumArgs, const IdentifierInfo **IIV)
Can create any sort of selector.
Selector getUnarySelector(const IdentifierInfo *ID)
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
bool isUnarySelector() const
bool isNull() const
Determine whether this is the empty selector.
unsigned getNumArgs() const
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
void CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion=AttributeCompletion::Attribute, const IdentifierInfo *Scope=nullptr)
QualType ProduceTemplateArgumentSignatureHelp(TemplateTy, ArrayRef< ParsedTemplateArgument >, SourceLocation LAngleLoc)
QualType ProduceCtorInitMemberSignatureHelp(Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy, ArrayRef< Expr * > ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc, bool Braced)
void CodeCompleteObjCClassForwardDecl(Scope *S)
void CodeCompleteNamespaceAliasDecl(Scope *S)
void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
void CodeCompleteObjCAtStatement(Scope *S)
void CodeCompleteUsing(Scope *S)
void CodeCompleteObjCMessageReceiver(Scope *S)
void CodeCompleteOperatorName(Scope *S)
void CodeCompleteUsingDirective(Scope *S)
void CodeCompleteObjCProtocolDecl(Scope *S)
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
ParserCompletionContext
Describes the context in which code completion occurs.
@ PCC_LocalDeclarationSpecifiers
Code completion occurs within a sequence of declaration specifiers within a function,...
@ PCC_MemberTemplate
Code completion occurs following one or more template headers within a class.
@ PCC_Condition
Code completion occurs within the condition of an if, while, switch, or for statement.
@ PCC_ParenthesizedExpression
Code completion occurs in a parenthesized expression, which might also be a type cast.
@ PCC_TopLevelOrExpression
Code completion occurs at top-level in a REPL session.
@ PCC_Class
Code completion occurs within a class, struct, or union.
@ PCC_ForInit
Code completion occurs at the beginning of the initialization statement (or expression) in a for loop...
@ PCC_Type
Code completion occurs where only a type is permitted.
@ PCC_ObjCImplementation
Code completion occurs within an Objective-C implementation or category implementation.
@ PCC_ObjCInterface
Code completion occurs within an Objective-C interface, protocol, or category.
@ PCC_Namespace
Code completion occurs at top-level or namespace context.
@ PCC_Expression
Code completion occurs within an expression.
@ PCC_RecoveryInFunction
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
@ PCC_ObjCInstanceVariableList
Code completion occurs within the list of instance variables in an Objective-C interface,...
@ PCC_Template
Code completion occurs following one or more template headers.
@ PCC_Statement
Code completion occurs within a statement, which may also be an expression or a declaration.
void CodeCompleteObjCAtDirective(Scope *S)
void CodeCompleteObjCPropertySetter(Scope *S)
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
void CodeCompleteCase(Scope *S)
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCInterfaceDecl(Scope *S)
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
void CodeCompletePreprocessorMacroName(bool IsDefinition)
void CodeCompleteInPreprocessorConditionalExclusion(Scope *S)
void CodeCompleteObjCAtExpression(Scope *S)
void CodeCompletePreprocessorExpression()
void CodeCompleteTypeQualifiers(DeclSpec &DS)
void CodeCompleteObjCPropertyDefinition(Scope *S)
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression)
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
void CodeCompleteAfterFunctionEquals(Declarator &D)
QualType ProduceConstructorSignatureHelp(QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args, SourceLocation OpenParLoc, bool Braced)
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for.
QualType ProduceCallSignatureHelp(Expr *Fn, ArrayRef< Expr * > Args, SourceLocation OpenParLoc)
Determines the preferred type of the current function argument, by examining the signatures of all po...
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< const IdentifierInfo * > SelIdents)
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, bool IsUsingDeclaration, QualType BaseType, QualType PreferredType)
void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled)
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCSelector(Scope *S, ArrayRef< const IdentifierInfo * > SelIdents)
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
void CodeCompleteObjCImplementationDecl(Scope *S)
void CodeCompleteAfterIf(Scope *S, bool IsBracedThen)
void CodeCompleteObjCMethodDecl(Scope *S, std::optional< bool > IsInstanceMethod, ParsedType ReturnType)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
void CodeCompleteNaturalLanguage()
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, const IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
void CodeCompleteInitializer(Scope *S, Decl *D)
void CodeCompleteNamespaceDecl(Scope *S)
void CodeCompleteDesignator(const QualType BaseType, llvm::ArrayRef< Expr * > InitExprs, const Designation &D)
Trigger code completion for a record of BaseType.
void CodeCompletePreprocessorDirective(bool InConditional)
SemaCodeCompletion(Sema &S, CodeCompleteConsumer *CompletionConsumer)
void CodeCompleteBracketDeclarator(Scope *S)
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCAtVisibility(Scope *S)
void CodeCompleteTag(Scope *S, unsigned TagSpec)
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar)
void CodeCompleteAvailabilityPlatformName()
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement, QualType PreferredType)
void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, bool IsParameter)
void CodeCompleteObjCPropertyGetter(Scope *S)
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS, QualType PreferredType)
ObjCInterfaceDecl * getObjCInterfaceDecl(const IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Find the protocol with the given name, if any.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
Sema - This implements semantic analysis and AST building for C.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs=true)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupNestedNameSpecifierName
Look up of a name that precedes the '::' scope resolution operator in C++.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
@ LookupAnyName
Look up any declaration with any name.
TemplateDecl * AdjustDeclIfTemplate(Decl *&Decl)
AdjustDeclIfTemplate - If the given decl happens to be a template, reset the parameter D to reference...
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
Preprocessor & getPreprocessor() const
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
IdentifierInfo * getSuperIdentifier() const
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ASTContext & getASTContext() const
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
ValueDecl * tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl, CXXScopeSpec &SS, ParsedType TemplateTypeTy, IdentifierInfo *MemberOrBase)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
const LangOptions & getLangOpts() const
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true, bool LoadExternal=true)
SemaCodeCompletion & CodeCompletion()
sema::FunctionScopeInfo * getCurFunction() const
void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool PartialOverloading=false)
Add the overload candidates named by callee and/or found by argument dependent lookup to the given ov...
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.
SourceManager & getSourceManager() const
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
ExternalSemaSource * getExternalSource() const
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
void AddFunctionCandidates(const UnresolvedSetImpl &Functions, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, bool SuppressUserConversions=false, bool PartialOverloading=false, bool FirstArgumentIsBase=false)
Add all of the function declarations in the given function set to the overload candidate set.
bool isAcceptableNestedNameSpecifier(const NamedDecl *SD, bool *CanCorrect=nullptr)
Determines whether the given declaration is an valid acceptable result for name lookup of a nested-na...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceManager & SourceMgr
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=true, bool AllowExplicitConversion=false, ADLCallKind IsADLCandidate=ADLCallKind::NotADL, ConversionSequenceList EarlyConversions={}, OverloadCandidateParamOrder PO={}, bool AggregateCandidateDeduction=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
Encodes a location in the source.
This class handles loading and caching of source files into memory.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
FileManager & getFileManager() const
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
SwitchStmt - This represents a 'switch' stmt.
Represents the declaration of a struct/union/class/enum.
A convenient class for passing around template argument information.
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
@ Type
The template argument is a type.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
bool hasParameterPack() const
Determine whether this template parameter list contains a parameter pack.
ArrayRef< NamedDecl * > asArray()
Represents a type template specialization; the template must be a class template, a type alias templa...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
TemplateTypeParmDecl * getDecl() const
The top declaration context.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Represents a declaration of a type.
Base wrapper for a particular "section" of type source info.
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
QualType getType() const
Get the type for which this source info wrapper provides information.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isBooleanType() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
bool isPointerType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isObjCObjectOrInterfaceType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isTemplateTypeParmType() const
bool isMemberPointerType() const
bool isObjCIdType() const
bool isObjCObjectType() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isObjCObjectPointerType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
std::optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Wrapper for source info for typedefs.
Represents a C++ unqualified-id that has been parsed.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
void append(iterator I, iterator E)
A set of unresolved declarations.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a C++11 virt-specifier-seq.
bool isOverrideSpecified() const
bool isFinalSpecified() const
Consumes visible declarations found when searching for all visible names within a given scope or cont...
A static requirement that can be used in a requires-expression to check properties of types and expre...
Retains information about a block that is currently being parsed.
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
SmallVector< SwitchInfo, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
CXCursorKind
Describes the kind of entity that a cursor refers to.
@ CXCursor_ObjCInterfaceDecl
An Objective-C @interface.
@ CXCursor_Namespace
A C++ namespace.
@ CXCursor_TypedefDecl
A typedef.
@ CXCursor_CXXAccessSpecifier
An access specifier.
@ CXCursor_EnumConstantDecl
An enumerator constant.
@ CXCursor_ConversionFunction
A C++ conversion function.
@ CXCursor_ConceptDecl
a concept declaration.
@ CXCursor_ClassTemplate
A C++ class template.
@ CXCursor_UnionDecl
A C or C++ union.
@ CXCursor_ObjCSynthesizeDecl
An Objective-C @synthesize definition.
@ CXCursor_ParmDecl
A function or method parameter.
@ CXCursor_FieldDecl
A field (in C) or non-static data member (in C++) in a struct, union, or C++ class.
@ CXCursor_CXXMethod
A C++ class method.
@ CXCursor_EnumDecl
An enumeration.
@ CXCursor_ObjCClassMethodDecl
An Objective-C class method.
@ CXCursor_TranslationUnit
Cursor that represents the translation unit itself.
@ CXCursor_ClassTemplatePartialSpecialization
A C++ class template partial specialization.
@ CXCursor_ObjCProtocolDecl
An Objective-C @protocol declaration.
@ CXCursor_FunctionTemplate
A C++ function template.
@ CXCursor_ObjCImplementationDecl
An Objective-C @implementation.
@ CXCursor_NonTypeTemplateParameter
A C++ non-type template parameter.
@ CXCursor_FunctionDecl
A function.
@ CXCursor_ObjCPropertyDecl
An Objective-C @property declaration.
@ CXCursor_Destructor
A C++ destructor.
@ CXCursor_ObjCIvarDecl
An Objective-C instance variable.
@ CXCursor_TypeAliasTemplateDecl
@ CXCursor_ObjCCategoryImplDecl
An Objective-C @implementation for a category.
@ CXCursor_ObjCDynamicDecl
An Objective-C @dynamic definition.
@ CXCursor_MacroDefinition
@ CXCursor_VarDecl
A variable.
@ CXCursor_TemplateTypeParameter
A C++ template type parameter.
@ CXCursor_TemplateTemplateParameter
A C++ template template parameter.
@ CXCursor_UnexposedDecl
A declaration whose specific kind is not exposed via this interface.
@ CXCursor_ObjCInstanceMethodDecl
An Objective-C instance method.
@ CXCursor_StructDecl
A C or C++ struct.
@ CXCursor_UsingDeclaration
A C++ using declaration.
@ CXCursor_LinkageSpec
A linkage specification, e.g.
@ CXCursor_ClassDecl
A C++ class.
@ CXCursor_ObjCCategoryDecl
An Objective-C @interface for a category.
@ CXCursor_StaticAssert
A static_assert or _Static_assert node.
@ CXCursor_ModuleImportDecl
A module import declaration.
@ CXCursor_MemberRef
A reference to a member of a struct, union, or class that occurs in some non-expression context,...
@ CXCursor_NamespaceAlias
A C++ namespace alias declaration.
@ CXCursor_Constructor
A C++ constructor.
@ CXCursor_FriendDecl
a friend declaration.
@ CXCursor_TypeAliasDecl
A C++ alias declaration.
@ CXCursor_UsingDirective
A C++ using directive.
@ CXAvailability_Available
The entity is available.
@ CXAvailability_Deprecated
The entity is available, but has been deprecated (and its use is not recommended).
@ CXAvailability_NotAvailable
The entity is not available; any use of it will be an error.
@ kind_nullability
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, bool WithGlobalNsPrefix=false)
Generates a QualType that can be used to name the same type if used at the end of the current transla...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool Alloc(InterpState &S, CodePtr OpPC, const Descriptor *Desc)
bool Add(InterpState &S, CodePtr OpPC)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
QualType getDeclUsageType(ASTContext &C, const NamedDecl *ND)
Determine the type that this declaration will have if it is used as a type or in an expression.
bool isReservedInAllContexts(ReservedIdentifierStatus Status)
Determine whether an identifier is reserved in all contexts.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
@ RQ_None
No ref-qualifier was provided.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
const RawComment * getParameterComment(const ASTContext &Ctx, const CodeCompleteConsumer::OverloadCandidate &Result, unsigned ArgIndex)
Get the documentation comment used to produce CodeCompletionString::BriefComment for OverloadCandidat...
@ LCK_This
Capturing the *this object by reference.
@ IK_ConstructorName
A constructor name.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ Property
The type of a property.
@ Parameter
The parameter type of a method or function.
@ Result
The result type of a method or function.
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion.
const RawComment * getPatternCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Pattern.
@ CCF_ExactTypeMatch
Divide by this factor when a code-completion result's type exactly matches the type we expect.
@ CCF_SimilarTypeMatch
Divide by this factor when a code-completion result's type is similar to the type we expect (e....
@ Interface
The "__interface" keyword.
@ Struct
The "struct" keyword.
@ Class
The "class" keyword.
@ Union
The "union" keyword.
@ Enum
The "enum" keyword.
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
const RawComment * getCompletionComment(const ASTContext &Ctx, const NamedDecl *Decl)
Get the documentation comment used to produce CodeCompletionString::BriefComment for RK_Declaration.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, OverloadCandidateSet::CandidateSetKind Kind)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
@ CCP_Type
Priority for a type.
@ CCP_ObjC_cmd
Priority for the Objective-C "_cmd" implicit parameter.
@ CCP_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.
const FunctionProtoType * T
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name.
bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function)
llvm::StringRef getAsString(SyncScope S)
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ 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.
@ StartsWithDoubleUnderscore
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
bool IntegralConstantExpression
SmallVector< Decl *, 4 > IgnoreDecls
CodeCompleteExpressionData(QualType PreferredType=QualType(), bool IsParenthesized=false)
Represents a complete lambda introducer.
SmallVector< LambdaCapture, 4 > Captures
LambdaCaptureDefault Default
a linked list of methods with the same selector name but different signatures.
ObjCMethodDecl * getMethod() const
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
static ArrayRef< const ParsedAttrInfo * > getAllBuiltin()
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressUnwrittenScope
Suppress printing parts of scope specifiers that are never written, e.g., for anonymous namespaces.
unsigned AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g.,...
unsigned CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
unsigned SuppressScope
Suppresses printing of scope specifiers.
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.