46#include "llvm/ADT/ArrayRef.h"
47#include "llvm/ADT/DenseSet.h"
48#include "llvm/ADT/SmallBitVector.h"
49#include "llvm/ADT/SmallPtrSet.h"
50#include "llvm/ADT/SmallString.h"
51#include "llvm/ADT/StringSwitch.h"
52#include "llvm/ADT/Twine.h"
53#include "llvm/ADT/iterator_range.h"
54#include "llvm/Support/Casting.h"
55#include "llvm/Support/Path.h"
56#include "llvm/Support/raw_ostream.h"
75 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
81 std::vector<Result> Results;
88 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
93 class ShadowMapEntry {
98 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector *> DeclOrVector;
102 unsigned SingleDeclIndex = 0;
105 ShadowMapEntry() =
default;
106 ShadowMapEntry(
const ShadowMapEntry &) =
delete;
107 ShadowMapEntry(ShadowMapEntry &&Move) { *
this = std::move(Move); }
108 ShadowMapEntry &operator=(
const ShadowMapEntry &) =
delete;
109 ShadowMapEntry &operator=(ShadowMapEntry &&Move) {
110 SingleDeclIndex =
Move.SingleDeclIndex;
111 DeclOrVector =
Move.DeclOrVector;
112 Move.DeclOrVector =
nullptr;
117 if (DeclOrVector.isNull()) {
120 SingleDeclIndex = Index;
125 DeclOrVector.dyn_cast<
const NamedDecl *>()) {
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())
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 * {
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())
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;
5745 if (!
Unresolved->isSpecificBuiltinType(BuiltinType::Dependent)) {
5747 if (!
Auto || !
Auto->isUndeducedAutoType())
5751 if (
const CallExpr *CE = llvm::dyn_cast<CallExpr>(
E)) {
5754 Callee->isSpecificPlaceholderType(BuiltinType::BoundMember))
5760 Callee = FnTypePtr->getPointeeType();
5762 Callee = BPT->getPointeeType();
5765 return FnType->getReturnType().getNonReferenceType();
5768 if (
const auto *OE = llvm::dyn_cast<OverloadExpr>(CE->
getCallee())) {
5772 const Type *Common =
nullptr;
5773 for (
const auto *
D : OE->decls()) {
5775 if (
const auto *FD = llvm::dyn_cast<FunctionDecl>(
D))
5776 ReturnType = FD->getReturnType();
5777 else if (
const auto *FTD = llvm::dyn_cast<FunctionTemplateDecl>(
D))
5778 ReturnType = FTD->getTemplatedDecl()->getReturnType();
5781 const Type *Candidate =
5783 if (Common && Common != Candidate)
5787 if (Common !=
nullptr)
5792 if (
const auto *CDSME = llvm::dyn_cast<CXXDependentScopeMemberExpr>(
E)) {
5794 ? CDSME->getBaseType()
5795 : getApproximateType(CDSME->getBase());
5796 if (CDSME->isArrow() && !
Base.isNull())
5802 if (RD && RD->isCompleteDefinition()) {
5804 for (
const auto *
Member : RD->lookupDependentName(
5806 return llvm::isa<ValueDecl>(Member);
5808 return llvm::cast<ValueDecl>(
Member)->getType().getNonReferenceType();
5813 if (
const auto *DRE = llvm::dyn_cast<DeclRefExpr>(
E)) {
5814 if (
const auto *VD = llvm::dyn_cast<VarDecl>(DRE->getDecl())) {
5816 return getApproximateType(VD->getInit());
5819 if (
const auto *UO = llvm::dyn_cast<UnaryOperator>(
E)) {
5820 if (UO->getOpcode() == UnaryOperatorKind::UO_Deref) {
5823 if (
auto Pointee = getApproximateType(UO->getSubExpr())->getPointeeType();
5838 if (
auto *PLE = llvm::dyn_cast_or_null<ParenListExpr>(
Base)) {
5839 if (PLE->getNumExprs() == 0)
5841 Base = PLE->getExpr(PLE->getNumExprs() - 1);
5850 bool IsBaseExprStatement,
QualType PreferredType) {
5852 OtherOpBase = unwrapParenList(OtherOpBase);
5853 if (!
Base || !CodeCompleter)
5860 QualType ConvertedBaseType = getApproximateType(ConvertedBase.
get());
5882 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
5883 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
5884 &ResultBuilder::IsMember);
5886 auto DoCompletion = [&](
Expr *
Base,
bool IsArrow,
5887 std::optional<FixItHint> AccessOpFixIt) ->
bool {
5916 RD, std::move(AccessOpFixIt));
5917 }
else if (
const auto *TTPT =
5918 dyn_cast<TemplateTypeParmType>(BaseType.
getTypePtr())) {
5920 IsArrow ? ConceptInfo::Member::Arrow : ConceptInfo::Member::Dot;
5921 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
5922 if (R.Operator != Operator)
5925 R.render(SemaRef, CodeCompleter->getAllocator(),
5926 CodeCompleter->getCodeCompletionTUInfo()));
5928 Result.FixIts.push_back(*AccessOpFixIt);
5929 Results.AddResult(std::move(
Result));
5935 if (AccessOpFixIt) {
5943 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
5946 AddedProperties, Results, IsBaseExprStatement);
5952 SemaRef.
CurContext, AddedProperties, Results,
5953 IsBaseExprStatement,
false,
5960 if (AccessOpFixIt) {
5966 Class = ObjCPtr->getInterfaceDecl();
5972 CodeCompletionDeclConsumer Consumer(Results,
Class, BaseType);
5973 Results.setFilter(&ResultBuilder::IsObjCIvar);
5975 CodeCompleter->includeGlobals(),
5977 CodeCompleter->loadExternal());
5985 Results.EnterNewScope();
5987 bool CompletionSucceded = DoCompletion(
Base, IsArrow, std::nullopt);
5988 if (CodeCompleter->includeFixIts()) {
5991 CompletionSucceded |= DoCompletion(
5992 OtherOpBase, !IsArrow,
5996 Results.ExitScope();
5998 if (!CompletionSucceded)
6003 Results.getCompletionContext(), Results.data(),
6009 bool IsBaseExprStatement) {
6017 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6018 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
6019 &ResultBuilder::IsMember);
6020 Results.EnterNewScope();
6024 AddedProperties, Results, IsBaseExprStatement,
6026 Results.ExitScope();
6028 Results.getCompletionContext(), Results.data(),
6036 ResultBuilder::LookupFilter Filter =
nullptr;
6041 Filter = &ResultBuilder::IsEnum;
6046 Filter = &ResultBuilder::IsUnion;
6053 Filter = &ResultBuilder::IsClassOrStruct;
6058 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
6061 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6062 CodeCompleter->getCodeCompletionTUInfo(), ContextKind);
6063 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6066 Results.setFilter(Filter);
6068 CodeCompleter->includeGlobals(),
6069 CodeCompleter->loadExternal());
6071 if (CodeCompleter->includeGlobals()) {
6073 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
6075 CodeCompleter->includeGlobals(),
6076 CodeCompleter->loadExternal());
6080 Results.getCompletionContext(), Results.data(),
6087 Results.AddResult(
"const");
6089 Results.AddResult(
"volatile");
6091 Results.AddResult(
"restrict");
6093 Results.AddResult(
"_Atomic");
6095 Results.AddResult(
"__unaligned");
6099 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6100 CodeCompleter->getCodeCompletionTUInfo(),
6102 Results.EnterNewScope();
6104 Results.ExitScope();
6106 Results.getCompletionContext(), Results.data(),
6112 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6113 CodeCompleter->getCodeCompletionTUInfo(),
6115 Results.EnterNewScope();
6118 Results.AddResult(
"noexcept");
6120 !
D.isStaticMember()) {
6122 Results.AddResult(
"final");
6124 Results.AddResult(
"override");
6127 Results.ExitScope();
6129 Results.getCompletionContext(), Results.data(),
6134 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
6147 if (!
type->isEnumeralType()) {
6149 Data.IntegralConstantExpression =
true;
6150 CodeCompleteExpression(S,
Data);
6164 CoveredEnumerators Enumerators;
6166 SC = SC->getNextSwitchCase()) {
6167 CaseStmt *Case = dyn_cast<CaseStmt>(SC);
6172 if (
auto *DRE = dyn_cast<DeclRefExpr>(CaseVal))
6173 if (
auto *Enumerator =
6174 dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
6181 Enumerators.Seen.insert(Enumerator);
6194 Enumerators.SuggestedQualifier = DRE->getQualifier();
6199 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6200 CodeCompleter->getCodeCompletionTUInfo(),
6205 if (CodeCompleter->includeMacros()) {
6209 Results.getCompletionContext(), Results.data(),
6214 if (Args.size() && !Args.data())
6217 for (
unsigned I = 0; I != Args.size(); ++I)
6238 if (Candidate.Function) {
6239 if (Candidate.Function->isDeleted())
6242 Candidate.Function) &&
6243 Candidate.Function->getNumParams() <= ArgSize &&
6252 if (Candidate.Viable)
6266 for (
auto &Candidate : Candidates) {
6267 QualType CandidateParamType = Candidate.getParamType(N);
6268 if (CandidateParamType.
isNull())
6270 if (ParamType.
isNull()) {
6271 ParamType = CandidateParamType;
6288 if (Candidates.empty())
6292 SemaRef, CurrentArg, Candidates.data(), Candidates.size(), OpenParLoc,
6303 if (
const auto *
T = Fn->getType().getTypePtr()->getAs<
TypedefType>()) {
6304 Target =
T->getDecl()->getTypeSourceInfo()->getTypeLoc();
6306 }
else if (
const auto *DR = dyn_cast<DeclRefExpr>(Fn)) {
6307 const auto *
D = DR->getDecl();
6308 if (
const auto *
const VD = dyn_cast<VarDecl>(
D)) {
6309 Target = VD->getTypeSourceInfo()->getTypeLoc();
6311 }
else if (
const auto *ME = dyn_cast<MemberExpr>(Fn)) {
6312 const auto *MD = ME->getMemberDecl();
6313 if (
const auto *FD = dyn_cast<FieldDecl>(MD)) {
6314 Target = FD->getTypeSourceInfo()->getTypeLoc();
6328 Target = A.getModifiedLoc();
6348 Fn = unwrapParenList(Fn);
6349 if (!CodeCompleter || !Fn)
6359 auto ArgsWithoutDependentTypes =
6364 Expr *NakedFn = Fn->IgnoreParenCasts();
6369 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn)) {
6373 }
else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
6375 if (UME->hasExplicitTemplateArgs()) {
6376 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
6377 TemplateArgs = &TemplateArgsBuffer;
6382 1, UME->isImplicitAccess() ?
nullptr : UME->getBase());
6383 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6384 ArgsWithoutDependentTypes.end());
6386 Decls.
append(UME->decls_begin(), UME->decls_end());
6387 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
6391 FirstArgumentIsBase);
6394 if (
auto *MCE = dyn_cast<MemberExpr>(NakedFn))
6395 FD = dyn_cast<FunctionDecl>(MCE->getMemberDecl());
6396 else if (
auto *DRE = dyn_cast<DeclRefExpr>(NakedFn))
6397 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
6405 ArgsWithoutDependentTypes, CandidateSet,
6415 getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
6420 ArgExprs.append(ArgsWithoutDependentTypes.begin(),
6421 ArgsWithoutDependentTypes.end());
6439 ArgsWithoutDependentTypes.size(),
6475static std::optional<unsigned>
6478 static constexpr unsigned Invalid = std::numeric_limits<unsigned>::max();
6484 unsigned ArgsAfterDesignator = 0;
6485 for (
const Expr *Arg : Args) {
6486 if (
const auto *DIE = dyn_cast<DesignatedInitExpr>(Arg)) {
6487 if (DIE->size() == 1 && DIE->getDesignator(0)->isFieldDesignator()) {
6488 DesignatedFieldName = DIE->getDesignator(0)->getFieldName();
6489 ArgsAfterDesignator = 0;
6493 }
else if (isa<DesignatedInitUpdateExpr>(Arg)) {
6496 ++ArgsAfterDesignator;
6499 if (!DesignatedFieldName)
6500 return std::nullopt;
6504 unsigned DesignatedIndex = 0;
6505 const FieldDecl *DesignatedField =
nullptr;
6506 for (
const auto *Field :
Aggregate.getAggregate()->fields()) {
6507 if (Field->getIdentifier() == DesignatedFieldName) {
6508 DesignatedField = Field;
6513 if (!DesignatedField)
6517 unsigned AggregateSize =
Aggregate.getNumParams();
6518 while (DesignatedIndex < AggregateSize &&
6519 Aggregate.getParamDecl(DesignatedIndex) != DesignatedField)
6523 return DesignatedIndex + ArgsAfterDesignator + 1;
6546 if (Braced && !RD->
isUnion() &&
6551 if (
auto NextIndex =
6554 if (*NextIndex >= AggregateSize)
6556 Results.push_back(AggregateSig);
6562 if (Args.size() < AggregateSize)
6563 Results.push_back(AggregateSig);
6572 if (
auto *FD = dyn_cast<FunctionDecl>(
C)) {
6575 if (Braced && getLangOpts().
CPlusPlus &&
6583 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(
C)) {
6584 if (Braced && getLangOpts().
CPlusPlus &&
6590 nullptr, Args, CandidateSet,
6611 dyn_cast<CXXConstructorDecl>(ConstructorDecl);
6616 Constructor->getParent(), SS, TemplateTypeTy, II))
6617 return ProduceConstructorSignatureHelp(MemberDecl->getType(),
6618 MemberDecl->getLocation(), ArgExprs,
6619 OpenParLoc, Braced);
6627 if (Index < Params.
size())
6630 Param = Params.
asArray().back();
6636 return llvm::isa<TemplateTypeParmDecl>(Param);
6638 return llvm::isa<NonTypeTemplateParmDecl>(Param);
6640 return llvm::isa<TemplateTemplateParmDecl>(Param);
6642 llvm_unreachable(
"Unhandled switch case");
6648 if (!CodeCompleter || !ParsedTemplate)
6654 bool Matches =
true;
6655 for (
unsigned I = 0; I < Args.size(); ++I) {
6662 Results.emplace_back(TD);
6670 if (
const auto *TD = llvm::dyn_cast<TemplateDecl>(ND))
6683 if (
D.isArrayDesignator() ||
D.isArrayRangeDesignator()) {
6687 assert(
D.isFieldDesignator());
6689 if (RD && RD->isCompleteDefinition()) {
6690 for (
const auto *
Member : RD->lookup(
D.getFieldDecl()))
6692 NextType = FD->getType();
6697 BaseType = NextType;
6708 if (!RD || RD->fields().empty())
6713 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6714 CodeCompleter->getCodeCompletionTUInfo(), CCC);
6716 Results.EnterNewScope();
6717 for (
const Decl *
D : RD->decls()) {
6719 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(
D))
6720 FD = IFD->getAnonField();
6721 else if (
auto *DFD = dyn_cast<FieldDecl>(
D))
6731 Results.ExitScope();
6733 Results.getCompletionContext(), Results.data(),
6738 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(
D);
6740 CodeCompleteOrdinaryName(S, PCC_Expression);
6747 Data.IgnoreDecls.push_back(VD);
6749 CodeCompleteExpression(S,
Data);
6753 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6754 CodeCompleter->getCodeCompletionTUInfo(),
6756 Results.setFilter(&ResultBuilder::IsOrdinaryName);
6757 Results.EnterNewScope();
6759 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6761 CodeCompleter->includeGlobals(),
6762 CodeCompleter->loadExternal());
6768 Results.getCodeCompletionTUInfo());
6770 auto AddElseBodyPattern = [&] {
6775 Builder.AddPlaceholderChunk(
"statements");
6781 Builder.AddPlaceholderChunk(
"statement");
6785 Builder.AddTypedTextChunk(
"else");
6786 if (Results.includeCodePatterns())
6787 AddElseBodyPattern();
6788 Results.AddResult(Builder.TakeString());
6791 Builder.AddTypedTextChunk(
"else if");
6795 Builder.AddPlaceholderChunk(
"condition");
6797 Builder.AddPlaceholderChunk(
"expression");
6799 if (Results.includeCodePatterns()) {
6800 AddElseBodyPattern();
6802 Results.AddResult(Builder.TakeString());
6804 Results.ExitScope();
6806 if (S->getFnParent())
6809 if (CodeCompleter->includeMacros())
6813 Results.getCompletionContext(), Results.data(),
6818 bool EnteringContext,
6819 bool IsUsingDeclaration,
6822 if (SS.
isEmpty() || !CodeCompleter)
6837 ResultBuilder DummyResults(SemaRef, CodeCompleter->getAllocator(),
6838 CodeCompleter->getCodeCompletionTUInfo(), CC);
6839 if (!PreferredType.
isNull())
6840 DummyResults.setPreferredType(PreferredType);
6841 if (S->getEntity()) {
6842 CodeCompletionDeclConsumer Consumer(DummyResults, S->getEntity(),
6849 DummyResults.getCompletionContext(),
nullptr, 0);
6864 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6865 CodeCompleter->getCodeCompletionTUInfo(), CC);
6866 if (!PreferredType.
isNull())
6867 Results.setPreferredType(PreferredType);
6868 Results.EnterNewScope();
6873 if (!Results.empty() && NNS && NNS->
isDependent())
6874 Results.AddResult(
"template");
6879 if (
const auto *TTPT =
6880 dyn_cast_or_null<TemplateTypeParmType>(NNS->
getAsType())) {
6881 for (
const auto &R : ConceptInfo(*TTPT, S).members()) {
6882 if (R.Operator != ConceptInfo::Member::Colons)
6885 R.render(SemaRef, CodeCompleter->getAllocator(),
6886 CodeCompleter->getCodeCompletionTUInfo())));
6896 if (Ctx && !EnteringContext)
6898 Results.ExitScope();
6901 (CodeCompleter->includeNamespaceLevelDecls() || !Ctx->
isFileContext())) {
6902 CodeCompletionDeclConsumer Consumer(Results, Ctx, BaseType);
6906 CodeCompleter->loadExternal());
6910 Results.getCompletionContext(), Results.data(),
6921 Context.setIsUsingDeclaration(
true);
6923 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6924 CodeCompleter->getCodeCompletionTUInfo(), Context,
6925 &ResultBuilder::IsNestedNameSpecifier);
6926 Results.EnterNewScope();
6929 if (!S->isClassScope())
6934 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6936 CodeCompleter->includeGlobals(),
6937 CodeCompleter->loadExternal());
6938 Results.ExitScope();
6941 Results.getCompletionContext(), Results.data(),
6951 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6952 CodeCompleter->getCodeCompletionTUInfo(),
6954 &ResultBuilder::IsNamespaceOrAlias);
6955 Results.EnterNewScope();
6956 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
6958 CodeCompleter->includeGlobals(),
6959 CodeCompleter->loadExternal());
6960 Results.ExitScope();
6962 Results.getCompletionContext(), Results.data(),
6971 if (!S->getParent())
6972 Ctx = getASTContext().getTranslationUnitDecl();
6974 bool SuppressedGlobalResults =
6975 Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
6977 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
6978 CodeCompleter->getCodeCompletionTUInfo(),
6979 SuppressedGlobalResults
6982 &ResultBuilder::IsNamespace);
6984 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
6989 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
6994 OrigToLatest[NS->getFirstDecl()] = *NS;
6998 Results.EnterNewScope();
6999 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
7000 NS = OrigToLatest.begin(),
7001 NSEnd = OrigToLatest.end();
7007 Results.ExitScope();
7011 Results.getCompletionContext(), Results.data(),
7020 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7021 CodeCompleter->getCodeCompletionTUInfo(),
7023 &ResultBuilder::IsNamespaceOrAlias);
7024 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7026 CodeCompleter->includeGlobals(),
7027 CodeCompleter->loadExternal());
7029 Results.getCompletionContext(), Results.data(),
7038 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7039 CodeCompleter->getCodeCompletionTUInfo(),
7041 &ResultBuilder::IsType);
7042 Results.EnterNewScope();
7046#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
7047 if (OO_##Name != OO_Conditional) \
7048 Results.AddResult(Result(Spelling));
7049#include "clang/Basic/OperatorKinds.def"
7052 Results.allowNestedNameSpecifiers();
7053 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7055 CodeCompleter->includeGlobals(),
7056 CodeCompleter->loadExternal());
7060 Results.ExitScope();
7063 Results.getCompletionContext(), Results.data(),
7074 auto *Constructor = dyn_cast<CXXConstructorDecl>(ConstructorD);
7078 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7079 CodeCompleter->getCodeCompletionTUInfo(),
7081 Results.EnterNewScope();
7086 for (
unsigned I = 0,
E = Initializers.size(); I !=
E; ++I) {
7087 if (Initializers[I]->isBaseInitializer())
7088 InitializedBases.insert(getASTContext().getCanonicalType(
7089 QualType(Initializers[I]->getBaseClass(), 0)));
7091 InitializedFields.insert(
7092 cast<FieldDecl>(Initializers[I]->getAnyMember()));
7097 bool SawLastInitializer = Initializers.empty();
7100 auto GenerateCCS = [&](
const NamedDecl *ND,
const char *Name) {
7102 Results.getCodeCompletionTUInfo());
7103 Builder.AddTypedTextChunk(Name);
7105 if (
const auto *
Function = dyn_cast<FunctionDecl>(ND))
7107 else if (
const auto *FunTemplDecl = dyn_cast<FunctionTemplateDecl>(ND))
7109 FunTemplDecl->getTemplatedDecl(), Builder);
7111 return Builder.TakeString();
7113 auto AddDefaultCtorInit = [&](
const char *Name,
const char *
Type,
7116 Results.getCodeCompletionTUInfo());
7117 Builder.AddTypedTextChunk(Name);
7119 Builder.AddPlaceholderChunk(
Type);
7123 Builder.TakeString(), ND,
7125 if (isa<FieldDecl>(ND))
7127 return Results.AddResult(CCR);
7130 Builder.TakeString(),
7134 const char *Name,
const FieldDecl *FD) {
7136 return AddDefaultCtorInit(Name,
7137 FD ? Results.getAllocator().CopyString(
7138 FD->getType().getAsString(Policy))
7142 if (Ctors.begin() == Ctors.end())
7143 return AddDefaultCtorInit(Name, Name, RD);
7147 Results.AddResult(CCR);
7151 const char *BaseName =
7152 Results.getAllocator().CopyString(
Base.getType().getAsString(Policy));
7153 const auto *RD =
Base.getType()->getAsCXXRecordDecl();
7158 auto AddField = [&](
const FieldDecl *FD) {
7159 const char *FieldName =
7160 Results.getAllocator().CopyString(FD->getIdentifier()->getName());
7161 const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl();
7167 for (
const auto &
Base : ClassDecl->
bases()) {
7168 if (!InitializedBases
7169 .insert(getASTContext().getCanonicalType(
Base.getType()))
7171 SawLastInitializer =
7172 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7173 getASTContext().hasSameUnqualifiedType(
7174 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7179 SawLastInitializer =
false;
7183 for (
const auto &
Base : ClassDecl->
vbases()) {
7184 if (!InitializedBases
7185 .insert(getASTContext().getCanonicalType(
Base.getType()))
7187 SawLastInitializer =
7188 !Initializers.empty() && Initializers.back()->isBaseInitializer() &&
7189 getASTContext().hasSameUnqualifiedType(
7190 Base.getType(),
QualType(Initializers.back()->getBaseClass(), 0));
7195 SawLastInitializer =
false;
7199 for (
auto *Field : ClassDecl->
fields()) {
7200 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
7202 SawLastInitializer = !Initializers.empty() &&
7203 Initializers.back()->isAnyMemberInitializer() &&
7204 Initializers.back()->getAnyMember() == Field;
7208 if (!Field->getDeclName())
7212 SawLastInitializer =
false;
7214 Results.ExitScope();
7217 Results.getCompletionContext(), Results.data(),
7232 bool AfterAmpersand) {
7233 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7234 CodeCompleter->getCodeCompletionTUInfo(),
7236 Results.EnterNewScope();
7240 bool IncludedThis =
false;
7243 IncludedThis =
true;
7252 for (
const auto *
D : S->decls()) {
7253 const auto *Var = dyn_cast<VarDecl>(
D);
7254 if (!Var || !Var->hasLocalStorage() || Var->hasAttr<BlocksAttr>())
7257 if (Known.insert(Var->getIdentifier()).second)
7267 Results.ExitScope();
7270 Results.getCompletionContext(), Results.data(),
7277 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7278 CodeCompleter->getCodeCompletionTUInfo(),
7280 auto ShouldAddDefault = [&
D,
this]() {
7281 if (!
D.isFunctionDeclarator())
7283 auto &
Id =
D.getName();
7289 D.getFunctionTypeInfo().NumParams <= 1)
7292 auto Op =
Id.OperatorFunctionId.Operator;
7295 if (Op == OverloadedOperatorKind::OO_Equal)
7297 if (getLangOpts().CPlusPlus20 &&
7298 (Op == OverloadedOperatorKind::OO_EqualEqual ||
7299 Op == OverloadedOperatorKind::OO_ExclaimEqual ||
7300 Op == OverloadedOperatorKind::OO_Less ||
7301 Op == OverloadedOperatorKind::OO_LessEqual ||
7302 Op == OverloadedOperatorKind::OO_Greater ||
7303 Op == OverloadedOperatorKind::OO_GreaterEqual ||
7304 Op == OverloadedOperatorKind::OO_Spaceship))
7310 Results.EnterNewScope();
7311 if (ShouldAddDefault())
7312 Results.AddResult(
"default");
7315 Results.AddResult(
"delete");
7316 Results.ExitScope();
7318 Results.getCompletionContext(), Results.data(),
7324#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
7327 ResultBuilder &Results,
bool NeedAt) {
7333 Results.getCodeCompletionTUInfo());
7334 if (LangOpts.ObjC) {
7338 Builder.AddPlaceholderChunk(
"property");
7339 Results.AddResult(
Result(Builder.TakeString()));
7344 Builder.AddPlaceholderChunk(
"property");
7345 Results.AddResult(
Result(Builder.TakeString()));
7350 ResultBuilder &Results,
bool NeedAt) {
7356 if (LangOpts.ObjC) {
7371 Results.getCodeCompletionTUInfo());
7376 Builder.AddPlaceholderChunk(
"name");
7377 Results.AddResult(
Result(Builder.TakeString()));
7379 if (Results.includeCodePatterns()) {
7385 Builder.AddPlaceholderChunk(
"class");
7386 Results.AddResult(
Result(Builder.TakeString()));
7391 Builder.AddPlaceholderChunk(
"protocol");
7392 Results.AddResult(
Result(Builder.TakeString()));
7397 Builder.AddPlaceholderChunk(
"class");
7398 Results.AddResult(
Result(Builder.TakeString()));
7402 Builder.AddTypedTextChunk(
7405 Builder.AddPlaceholderChunk(
"alias");
7407 Builder.AddPlaceholderChunk(
"class");
7408 Results.AddResult(
Result(Builder.TakeString()));
7410 if (Results.getSema().getLangOpts().Modules) {
7414 Builder.AddPlaceholderChunk(
"module");
7415 Results.AddResult(
Result(Builder.TakeString()));
7420 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7421 CodeCompleter->getCodeCompletionTUInfo(),
7423 Results.EnterNewScope();
7430 Results.ExitScope();
7432 Results.getCompletionContext(), Results.data(),
7439 Results.getCodeCompletionTUInfo());
7442 const char *EncodeType =
"char[]";
7443 if (Results.getSema().getLangOpts().CPlusPlus ||
7444 Results.getSema().getLangOpts().ConstStrings)
7445 EncodeType =
"const char[]";
7446 Builder.AddResultTypeChunk(EncodeType);
7449 Builder.AddPlaceholderChunk(
"type-name");
7451 Results.AddResult(
Result(Builder.TakeString()));
7454 Builder.AddResultTypeChunk(
"Protocol *");
7457 Builder.AddPlaceholderChunk(
"protocol-name");
7459 Results.AddResult(
Result(Builder.TakeString()));
7462 Builder.AddResultTypeChunk(
"SEL");
7465 Builder.AddPlaceholderChunk(
"selector");
7467 Results.AddResult(
Result(Builder.TakeString()));
7470 Builder.AddResultTypeChunk(
"NSString *");
7472 Builder.AddPlaceholderChunk(
"string");
7473 Builder.AddTextChunk(
"\"");
7474 Results.AddResult(
Result(Builder.TakeString()));
7477 Builder.AddResultTypeChunk(
"NSArray *");
7479 Builder.AddPlaceholderChunk(
"objects, ...");
7481 Results.AddResult(
Result(Builder.TakeString()));
7484 Builder.AddResultTypeChunk(
"NSDictionary *");
7486 Builder.AddPlaceholderChunk(
"key");
7489 Builder.AddPlaceholderChunk(
"object, ...");
7491 Results.AddResult(
Result(Builder.TakeString()));
7494 Builder.AddResultTypeChunk(
"id");
7496 Builder.AddPlaceholderChunk(
"expression");
7498 Results.AddResult(
Result(Builder.TakeString()));
7504 Results.getCodeCompletionTUInfo());
7506 if (Results.includeCodePatterns()) {
7511 Builder.AddPlaceholderChunk(
"statements");
7513 Builder.AddTextChunk(
"@catch");
7515 Builder.AddPlaceholderChunk(
"parameter");
7518 Builder.AddPlaceholderChunk(
"statements");
7520 Builder.AddTextChunk(
"@finally");
7522 Builder.AddPlaceholderChunk(
"statements");
7524 Results.AddResult(
Result(Builder.TakeString()));
7530 Builder.AddPlaceholderChunk(
"expression");
7531 Results.AddResult(
Result(Builder.TakeString()));
7533 if (Results.includeCodePatterns()) {
7538 Builder.AddPlaceholderChunk(
"expression");
7541 Builder.AddPlaceholderChunk(
"statements");
7543 Results.AddResult(
Result(Builder.TakeString()));
7548 ResultBuilder &Results,
bool NeedAt) {
7558 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7559 CodeCompleter->getCodeCompletionTUInfo(),
7561 Results.EnterNewScope();
7563 Results.ExitScope();
7565 Results.getCompletionContext(), Results.data(),
7570 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7571 CodeCompleter->getCodeCompletionTUInfo(),
7573 Results.EnterNewScope();
7576 Results.ExitScope();
7578 Results.getCompletionContext(), Results.data(),
7583 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7584 CodeCompleter->getCodeCompletionTUInfo(),
7586 Results.EnterNewScope();
7588 Results.ExitScope();
7590 Results.getCompletionContext(), Results.data(),
7598 if (Attributes & NewFlag)
7601 Attributes |= NewFlag;
7609 unsigned AssignCopyRetMask =
7615 if (AssignCopyRetMask &&
7634 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7635 CodeCompleter->getCodeCompletionTUInfo(),
7637 Results.EnterNewScope();
7674 Results.getCodeCompletionTUInfo());
7683 Results.getCodeCompletionTUInfo());
7696 Results.ExitScope();
7698 Results.getCompletionContext(), Results.data(),
7712 bool AllowSameLength =
true) {
7713 unsigned NumSelIdents = SelIdents.size();
7726 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
7729 for (
unsigned I = 0; I != NumSelIdents; ++I)
7739 bool AllowSameLength =
true) {
7773 ResultBuilder &Results,
bool InOriginalClass =
true,
7774 bool IsRootClass =
false) {
7778 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
7782 if (M->isInstanceMethod() == WantInstanceMethods ||
7783 (IsRootClass && !WantInstanceMethods)) {
7789 if (!Selectors.insert(M->getSelector()).second)
7792 Result R =
Result(M, Results.getBasePriority(M),
nullptr);
7793 R.StartParameter = SelIdents.size();
7794 R.AllParametersAreInformative = (WantKind !=
MK_Any);
7795 if (!InOriginalClass)
7797 Results.MaybeAddResult(R, CurContext);
7802 if (
const auto *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
7803 if (Protocol->hasDefinition()) {
7805 Protocol->getReferencedProtocols();
7807 E = Protocols.
end();
7809 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7810 Selectors, AllowSameLength, Results,
false, IsRootClass);
7819 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7820 Selectors, AllowSameLength, Results,
false, IsRootClass);
7824 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
7825 CurContext, Selectors, AllowSameLength, Results,
7826 InOriginalClass, IsRootClass);
7830 CatDecl->getReferencedProtocols();
7832 E = Protocols.
end();
7834 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
7835 Selectors, AllowSameLength, Results,
false, IsRootClass);
7839 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7840 Selectors, AllowSameLength, Results, InOriginalClass,
7848 SelIdents, CurContext, Selectors, AllowSameLength, Results,
7853 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
7854 Selectors, AllowSameLength, Results, InOriginalClass,
7861 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7864 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7872 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7873 CodeCompleter->getCodeCompletionTUInfo(),
7875 Results.EnterNewScope();
7881 Results.ExitScope();
7883 Results.getCompletionContext(), Results.data(),
7890 dyn_cast_or_null<ObjCInterfaceDecl>(SemaRef.
CurContext);
7893 dyn_cast_or_null<ObjCCategoryDecl>(SemaRef.
CurContext))
7901 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7902 CodeCompleter->getCodeCompletionTUInfo(),
7904 Results.EnterNewScope();
7911 Results.ExitScope();
7913 Results.getCompletionContext(), Results.data(),
7919 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
7920 CodeCompleter->getCodeCompletionTUInfo(),
7922 Results.EnterNewScope();
7925 bool AddedInOut =
false;
7928 Results.AddResult(
"in");
7929 Results.AddResult(
"inout");
7934 Results.AddResult(
"out");
7936 Results.AddResult(
"inout");
7941 Results.AddResult(
"bycopy");
7942 Results.AddResult(
"byref");
7943 Results.AddResult(
"oneway");
7946 Results.AddResult(
"nonnull");
7947 Results.AddResult(
"nullable");
7948 Results.AddResult(
"null_unspecified");
7958 Results.getCodeCompletionTUInfo(),
7960 Builder.AddTypedTextChunk(
"IBAction");
7962 Builder.AddPlaceholderChunk(
"selector");
7965 Builder.AddTextChunk(
"id");
7967 Builder.AddTextChunk(
"sender");
7978 Results.ExitScope();
7981 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
7982 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
7984 CodeCompleter->includeGlobals(),
7985 CodeCompleter->loadExternal());
7987 if (CodeCompleter->includeMacros())
7991 Results.getCompletionContext(), Results.data(),
8000 auto *Msg = dyn_cast_or_null<ObjCMessageExpr>(
E);
8018 switch (Msg->getReceiverKind()) {
8022 IFace = ObjType->getInterface();
8026 QualType T = Msg->getInstanceReceiver()->getType();
8028 IFace = Ptr->getInterfaceDecl();
8042 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
8043 .Case(
"retain", IFace)
8044 .Case(
"strong", IFace)
8045 .Case(
"autorelease", IFace)
8046 .Case(
"copy", IFace)
8047 .Case(
"copyWithZone", IFace)
8048 .Case(
"mutableCopy", IFace)
8049 .Case(
"mutableCopyWithZone", IFace)
8050 .Case(
"awakeFromCoder", IFace)
8051 .Case(
"replacementObjectFromCoder", IFace)
8052 .Case(
"class", IFace)
8053 .Case(
"classForCoder", IFace)
8054 .Case(
"superclass", Super)
8057 return llvm::StringSwitch<ObjCInterfaceDecl *>(
Id->getName())
8059 .Case(
"alloc", IFace)
8060 .Case(
"allocWithZone", IFace)
8061 .Case(
"class", IFace)
8062 .Case(
"superclass", Super)
8085 ResultBuilder &Results) {
8096 while ((
Class =
Class->getSuperClass()) && !SuperMethod) {
8103 for (
const auto *Cat :
Class->known_categories()) {
8104 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
8122 CurP != CurPEnd; ++CurP, ++SuperP) {
8125 (*SuperP)->getType()))
8129 if (!(*CurP)->getIdentifier())
8135 Results.getCodeCompletionTUInfo());
8139 Results.getCompletionContext().getBaseType(), Builder);
8142 if (NeedSuperKeyword) {
8143 Builder.AddTypedTextChunk(
"super");
8149 if (NeedSuperKeyword)
8150 Builder.AddTextChunk(
8153 Builder.AddTypedTextChunk(
8157 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
8158 if (I > SelIdents.size())
8161 if (I < SelIdents.size())
8162 Builder.AddInformativeChunk(
8164 else if (NeedSuperKeyword || I > SelIdents.size()) {
8165 Builder.AddTextChunk(
8167 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8168 (*CurP)->getIdentifier()->getName()));
8170 Builder.AddTypedTextChunk(
8172 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
8173 (*CurP)->getIdentifier()->getName()));
8185 ResultBuilder Results(
8186 SemaRef, CodeCompleter->getAllocator(),
8187 CodeCompleter->getCodeCompletionTUInfo(),
8190 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
8191 : &ResultBuilder::IsObjCMessageReceiver);
8193 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
8194 Results.EnterNewScope();
8196 CodeCompleter->includeGlobals(),
8197 CodeCompleter->loadExternal());
8203 if (Iface->getSuperClass()) {
8204 Results.AddResult(
Result(
"super"));
8212 Results.ExitScope();
8214 if (CodeCompleter->includeMacros())
8217 Results.getCompletionContext(), Results.data(),
8227 CDecl = CurMethod->getClassInterface();
8236 if (CurMethod->isInstanceMethod()) {
8240 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
8241 AtArgumentExpression, CDecl);
8251 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
8253 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
8255 getASTContext().getTypeDeclType(TD)->getAs<ObjCObjectType>())
8256 CDecl = Iface->getInterface();
8257 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
8269 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
8270 SelIdents, AtArgumentExpression);
8279 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
8280 AtArgumentExpression,
8287 unsigned NumSelIdents) {
8289 ASTContext &Context = Results.getSema().Context;
8293 Result *ResultsData = Results.data();
8294 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
8295 Result &R = ResultsData[I];
8296 if (R.Kind == Result::RK_Declaration &&
8297 isa<ObjCMethodDecl>(R.Declaration)) {
8298 if (R.Priority <= BestPriority) {
8299 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
8300 if (NumSelIdents <= Method->param_size()) {
8302 Method->
parameters()[NumSelIdents - 1]->getType();
8303 if (R.Priority < BestPriority || PreferredType.
isNull()) {
8304 BestPriority = R.Priority;
8305 PreferredType = MyPreferredType;
8315 return PreferredType;
8321 bool AtArgumentExpression,
bool IsSuper,
8322 ResultBuilder &Results) {
8337 Results.EnterNewScope();
8344 Results.Ignore(SuperMethod);
8350 Results.setPreferredSelector(CurMethod->getSelector());
8355 Selectors, AtArgumentExpression, Results);
8362 for (uint32_t I = 0,
8373 for (SemaObjC::GlobalMethodPool::iterator
8378 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8382 Result R(MethList->getMethod(),
8383 Results.getBasePriority(MethList->getMethod()),
nullptr);
8384 R.StartParameter = SelIdents.size();
8385 R.AllParametersAreInformative =
false;
8386 Results.MaybeAddResult(R, SemaRef.
CurContext);
8391 Results.ExitScope();
8396 bool AtArgumentExpression,
bool IsSuper) {
8400 ResultBuilder Results(
8401 SemaRef, CodeCompleter->getAllocator(),
8402 CodeCompleter->getCodeCompletionTUInfo(),
8407 AtArgumentExpression, IsSuper, Results);
8414 if (AtArgumentExpression) {
8417 if (PreferredType.
isNull())
8418 CodeCompleteOrdinaryName(S, PCC_Expression);
8420 CodeCompleteExpression(S, PreferredType);
8425 Results.getCompletionContext(), Results.data(),
8435 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
8443 RecExpr = Conv.
get();
8457 return CodeCompleteObjCClassMessage(
8459 AtArgumentExpression, Super);
8464 }
else if (RecExpr && getLangOpts().CPlusPlus) {
8467 RecExpr = Conv.
get();
8468 ReceiverType = RecExpr->
getType();
8473 ResultBuilder Results(
8474 SemaRef, CodeCompleter->getAllocator(),
8475 CodeCompleter->getCodeCompletionTUInfo(),
8477 ReceiverType, SelIdents));
8479 Results.EnterNewScope();
8486 Results.Ignore(SuperMethod);
8492 Results.setPreferredSelector(CurMethod->getSelector());
8505 Selectors, AtArgumentExpression, Results);
8512 for (
auto *I : QualID->quals())
8514 AtArgumentExpression, Results);
8521 SemaRef.
CurContext, Selectors, AtArgumentExpression,
8525 for (
auto *I : IFacePtr->quals())
8527 AtArgumentExpression, Results);
8537 for (uint32_t I = 0,
8548 for (SemaObjC::GlobalMethodPool::iterator
8553 MethList && MethList->
getMethod(); MethList = MethList->getNext()) {
8557 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
8560 Result R(MethList->getMethod(),
8561 Results.getBasePriority(MethList->getMethod()),
nullptr);
8562 R.StartParameter = SelIdents.size();
8563 R.AllParametersAreInformative =
false;
8564 Results.MaybeAddResult(R, SemaRef.
CurContext);
8568 Results.ExitScope();
8575 if (AtArgumentExpression) {
8578 if (PreferredType.
isNull())
8579 CodeCompleteOrdinaryName(S, PCC_Expression);
8581 CodeCompleteExpression(S, PreferredType);
8586 Results.getCompletionContext(), Results.data(),
8593 Data.ObjCCollection =
true;
8599 Data.IgnoreDecls.push_back(*I);
8603 CodeCompleteExpression(S,
Data);
8611 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
8621 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8622 CodeCompleter->getCodeCompletionTUInfo(),
8624 Results.EnterNewScope();
8625 for (SemaObjC::GlobalMethodPool::iterator
8635 Results.getCodeCompletionTUInfo());
8637 Builder.AddTypedTextChunk(
8639 Results.AddResult(Builder.TakeString());
8643 std::string Accumulator;
8644 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
8645 if (I == SelIdents.size()) {
8646 if (!Accumulator.empty()) {
8647 Builder.AddInformativeChunk(
8648 Builder.getAllocator().CopyString(Accumulator));
8649 Accumulator.clear();
8656 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(Accumulator));
8657 Results.AddResult(Builder.TakeString());
8659 Results.ExitScope();
8662 Results.getCompletionContext(), Results.data(),
8669 bool OnlyForwardDeclarations,
8670 ResultBuilder &Results) {
8673 for (
const auto *
D : Ctx->
decls()) {
8675 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(
D))
8676 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
8678 Result(Proto, Results.getBasePriority(Proto),
nullptr), CurContext,
8685 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8686 CodeCompleter->getCodeCompletionTUInfo(),
8689 if (CodeCompleter->includeGlobals()) {
8690 Results.EnterNewScope();
8698 Results.Ignore(Protocol);
8704 Results.ExitScope();
8708 Results.getCompletionContext(), Results.data(),
8713 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8714 CodeCompleter->getCodeCompletionTUInfo(),
8717 if (CodeCompleter->includeGlobals()) {
8718 Results.EnterNewScope();
8724 Results.ExitScope();
8728 Results.getCompletionContext(), Results.data(),
8735 bool OnlyForwardDeclarations,
8736 bool OnlyUnimplemented,
8737 ResultBuilder &Results) {
8740 for (
const auto *
D : Ctx->
decls()) {
8742 if (
const auto *
Class = dyn_cast<ObjCInterfaceDecl>(
D))
8743 if ((!OnlyForwardDeclarations || !
Class->hasDefinition()) &&
8744 (!OnlyUnimplemented || !
Class->getImplementation()))
8752 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8753 CodeCompleter->getCodeCompletionTUInfo(),
8755 Results.EnterNewScope();
8757 if (CodeCompleter->includeGlobals()) {
8763 Results.ExitScope();
8766 Results.getCompletionContext(), Results.data(),
8771 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8772 CodeCompleter->getCodeCompletionTUInfo(),
8774 Results.EnterNewScope();
8776 if (CodeCompleter->includeGlobals()) {
8782 Results.ExitScope();
8785 Results.getCompletionContext(), Results.data(),
8791 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8792 CodeCompleter->getCodeCompletionTUInfo(),
8794 Results.EnterNewScope();
8799 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
8800 Results.Ignore(CurClass);
8802 if (CodeCompleter->includeGlobals()) {
8808 Results.ExitScope();
8811 Results.getCompletionContext(), Results.data(),
8816 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8817 CodeCompleter->getCodeCompletionTUInfo(),
8819 Results.EnterNewScope();
8821 if (CodeCompleter->includeGlobals()) {
8827 Results.ExitScope();
8830 Results.getCompletionContext(), Results.data(),
8838 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8839 CodeCompleter->getCodeCompletionTUInfo(),
8848 dyn_cast_or_null<ObjCInterfaceDecl>(CurClass)) {
8849 for (
const auto *Cat :
Class->visible_categories())
8850 CategoryNames.insert(Cat->getIdentifier());
8854 Results.EnterNewScope();
8856 for (
const auto *
D : TU->
decls())
8857 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(
D))
8858 if (CategoryNames.insert(
Category->getIdentifier()).second)
8862 Results.ExitScope();
8865 Results.getCompletionContext(), Results.data(),
8880 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
8882 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8883 CodeCompleter->getCodeCompletionTUInfo(),
8890 Results.EnterNewScope();
8891 bool IgnoreImplemented =
true;
8893 for (
const auto *Cat :
Class->visible_categories()) {
8894 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
8895 CategoryNames.insert(Cat->getIdentifier()).second)
8896 Results.AddResult(
Result(Cat, Results.getBasePriority(Cat),
nullptr),
8901 IgnoreImplemented =
false;
8903 Results.ExitScope();
8906 Results.getCompletionContext(), Results.data(),
8912 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8913 CodeCompleter->getCodeCompletionTUInfo(), CCContext);
8917 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8918 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8919 !isa<ObjCCategoryImplDecl>(Container)))
8924 for (
const auto *
D : Container->decls())
8925 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(
D))
8926 Results.Ignore(PropertyImpl->getPropertyDecl());
8930 Results.EnterNewScope();
8932 dyn_cast<ObjCImplementationDecl>(Container))
8935 AddedProperties, Results);
8938 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
8940 AddedProperties, Results);
8941 Results.ExitScope();
8944 Results.getCompletionContext(), Results.data(),
8951 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
8952 CodeCompleter->getCodeCompletionTUInfo(),
8957 dyn_cast_or_null<ObjCContainerDecl>(SemaRef.
CurContext);
8958 if (!Container || (!isa<ObjCImplementationDecl>(Container) &&
8959 !isa<ObjCCategoryImplDecl>(Container)))
8965 dyn_cast<ObjCImplementationDecl>(Container))
8966 Class = ClassImpl->getClassInterface();
8968 Class = cast<ObjCCategoryImplDecl>(Container)
8970 ->getClassInterface();
8973 QualType PropertyType = getASTContext().getObjCIdType();
8978 Property->getType().getNonReferenceType().getUnqualifiedType();
8981 Results.setPreferredType(PropertyType);
8986 Results.EnterNewScope();
8987 bool SawSimilarlyNamedIvar =
false;
8988 std::string NameWithPrefix;
8989 NameWithPrefix +=
'_';
8990 NameWithPrefix += PropertyName->getName();
8991 std::string NameWithSuffix = PropertyName->getName().str();
8992 NameWithSuffix +=
'_';
8995 Ivar = Ivar->getNextIvar()) {
8996 Results.AddResult(
Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
9001 if ((PropertyName == Ivar->getIdentifier() ||
9002 NameWithPrefix == Ivar->getName() ||
9003 NameWithSuffix == Ivar->getName())) {
9004 SawSimilarlyNamedIvar =
true;
9008 if (Results.size() &&
9009 Results.data()[Results.size() - 1].Kind ==
9011 Results.data()[Results.size() - 1].Declaration == Ivar)
9012 Results.data()[Results.size() - 1].Priority--;
9017 if (!SawSimilarlyNamedIvar) {
9028 PropertyType, getASTContext(), Policy, Allocator));
9029 Builder.AddTypedTextChunk(Allocator.CopyString(NameWithPrefix));
9034 Results.ExitScope();
9037 Results.getCompletionContext(), Results.data(),
9044 llvm::PointerIntPair<ObjCMethodDecl *, 1, bool>>
9053 std::optional<bool> WantInstanceMethods,
9056 bool InOriginalClass =
true) {
9059 if (!IFace->hasDefinition())
9062 IFace = IFace->getDefinition();
9066 IFace->getReferencedProtocols();
9068 E = Protocols.
end();
9071 KnownMethods, InOriginalClass);
9074 for (
auto *Cat : IFace->visible_categories()) {
9076 KnownMethods,
false);
9080 if (IFace->getSuperClass())
9082 WantInstanceMethods, ReturnType, KnownMethods,
9089 Category->getReferencedProtocols();
9091 E = Protocols.
end();
9094 KnownMethods, InOriginalClass);
9097 if (InOriginalClass &&
Category->getClassInterface())
9099 WantInstanceMethods, ReturnType, KnownMethods,
9105 if (!Protocol->hasDefinition())
9107 Protocol = Protocol->getDefinition();
9108 Container = Protocol;
9112 Protocol->getReferencedProtocols();
9114 E = Protocols.
end();
9117 KnownMethods,
false);
9123 for (
auto *M : Container->methods()) {
9124 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
9125 if (!ReturnType.
isNull() &&
9129 KnownMethods[M->getSelector()] =
9130 KnownMethodsMap::mapped_type(M, InOriginalClass);
9144 Builder.AddTextChunk(Builder.getAllocator().CopyString(Quals));
9145 Builder.AddTextChunk(
9156 if (
Class->getIdentifier() &&
Class->getIdentifier()->getName() == Name)
9165 bool IsInstanceMethod,
9168 ResultBuilder &Results) {
9170 if (!PropName || PropName->
getLength() == 0)
9188 const char *CopiedKey;
9191 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
9193 operator const char *() {
9197 return CopiedKey = Allocator.CopyString(Key);
9199 } Key(Allocator, PropName->
getName());
9202 std::string UpperKey = std::string(PropName->
getName());
9203 if (!UpperKey.empty())
9206 bool ReturnTypeMatchesProperty =
9210 bool ReturnTypeMatchesVoid = ReturnType.
isNull() || ReturnType->
isVoidType();
9213 if (IsInstanceMethod &&
9215 ReturnTypeMatchesProperty && !
Property->getGetterMethodDecl()) {
9220 Builder.AddTypedTextChunk(Key);
9227 if (IsInstanceMethod &&
9228 ((!ReturnType.
isNull() &&
9231 Property->getType()->isBooleanType())))) {
9232 std::string SelectorName = (Twine(
"is") + UpperKey).str();
9236 if (ReturnType.
isNull()) {
9238 Builder.AddTextChunk(
"BOOL");
9242 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9249 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
9250 !
Property->getSetterMethodDecl()) {
9251 std::string SelectorName = (Twine(
"set") + UpperKey).str();
9253 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9254 if (ReturnType.
isNull()) {
9256 Builder.AddTextChunk(
"void");
9260 Builder.AddTypedTextChunk(
9261 Allocator.CopyString(SelectorId->
getName() +
":"));
9264 Builder.AddTextChunk(Key);
9275 if (
const auto *ObjCPointer =
9300 if (IsInstanceMethod &&
9302 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
9306 if (ReturnType.
isNull()) {
9308 Builder.AddTextChunk(
"NSUInteger");
9312 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorId->
getName()));
9314 Result(Builder.TakeString(),
9315 std::min(IndexedGetterPriority, UnorderedGetterPriority),
9322 if (IsInstanceMethod &&
9324 std::string SelectorName = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
9326 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9327 if (ReturnType.
isNull()) {
9329 Builder.AddTextChunk(
"id");
9333 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9335 Builder.AddTextChunk(
"NSUInteger");
9337 Builder.AddTextChunk(
"index");
9338 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9344 if (IsInstanceMethod &&
9351 std::string SelectorName = (Twine(
Property->getName()) +
"AtIndexes").str();
9353 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9354 if (ReturnType.
isNull()) {
9356 Builder.AddTextChunk(
"NSArray *");
9360 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9362 Builder.AddTextChunk(
"NSIndexSet *");
9364 Builder.AddTextChunk(
"indexes");
9365 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9371 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9372 std::string SelectorName = (Twine(
"get") + UpperKey).str();
9376 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9377 if (ReturnType.
isNull()) {
9379 Builder.AddTextChunk(
"void");
9383 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9385 Builder.AddPlaceholderChunk(
"object-type");
9386 Builder.AddTextChunk(
" **");
9388 Builder.AddTextChunk(
"buffer");
9390 Builder.AddTypedTextChunk(
"range:");
9392 Builder.AddTextChunk(
"NSRange");
9394 Builder.AddTextChunk(
"inRange");
9395 Results.AddResult(
Result(Builder.TakeString(), IndexedGetterPriority,
9403 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9404 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
9408 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9409 if (ReturnType.
isNull()) {
9411 Builder.AddTextChunk(
"void");
9415 Builder.AddTypedTextChunk(
"insertObject:");
9417 Builder.AddPlaceholderChunk(
"object-type");
9418 Builder.AddTextChunk(
" *");
9420 Builder.AddTextChunk(
"object");
9422 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9424 Builder.AddPlaceholderChunk(
"NSUInteger");
9426 Builder.AddTextChunk(
"index");
9427 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9433 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9434 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
9438 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9439 if (ReturnType.
isNull()) {
9441 Builder.AddTextChunk(
"void");
9445 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9447 Builder.AddTextChunk(
"NSArray *");
9449 Builder.AddTextChunk(
"array");
9451 Builder.AddTypedTextChunk(
"atIndexes:");
9453 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9455 Builder.AddTextChunk(
"indexes");
9456 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9462 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9463 std::string SelectorName =
9464 (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
9466 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9467 if (ReturnType.
isNull()) {
9469 Builder.AddTextChunk(
"void");
9473 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9475 Builder.AddTextChunk(
"NSUInteger");
9477 Builder.AddTextChunk(
"index");
9478 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9484 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9485 std::string SelectorName = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
9487 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9488 if (ReturnType.
isNull()) {
9490 Builder.AddTextChunk(
"void");
9494 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9496 Builder.AddTextChunk(
"NSIndexSet *");
9498 Builder.AddTextChunk(
"indexes");
9499 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9505 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9506 std::string SelectorName =
9507 (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
9511 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9512 if (ReturnType.
isNull()) {
9514 Builder.AddTextChunk(
"void");
9518 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9520 Builder.AddPlaceholderChunk(
"NSUInteger");
9522 Builder.AddTextChunk(
"index");
9524 Builder.AddTypedTextChunk(
"withObject:");
9526 Builder.AddTextChunk(
"id");
9528 Builder.AddTextChunk(
"object");
9529 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9535 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9536 std::string SelectorName1 =
9537 (Twine(
"replace") + UpperKey +
"AtIndexes").str();
9538 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
9542 if (KnownSelectors.insert(Selectors.
getSelector(2, SelectorIds)).second) {
9543 if (ReturnType.
isNull()) {
9545 Builder.AddTextChunk(
"void");
9549 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName1 +
":"));
9551 Builder.AddPlaceholderChunk(
"NSIndexSet *");
9553 Builder.AddTextChunk(
"indexes");
9555 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName2 +
":"));
9557 Builder.AddTextChunk(
"NSArray *");
9559 Builder.AddTextChunk(
"array");
9560 Results.AddResult(
Result(Builder.TakeString(), IndexedSetterPriority,
9567 if (IsInstanceMethod &&
9573 ->
getName() ==
"NSEnumerator"))) {
9574 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
9578 if (ReturnType.
isNull()) {
9580 Builder.AddTextChunk(
"NSEnumerator *");
9584 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9585 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9591 if (IsInstanceMethod &&
9593 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
9595 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9596 if (ReturnType.
isNull()) {
9598 Builder.AddPlaceholderChunk(
"object-type");
9599 Builder.AddTextChunk(
" *");
9603 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9605 if (ReturnType.
isNull()) {
9606 Builder.AddPlaceholderChunk(
"object-type");
9607 Builder.AddTextChunk(
" *");
9610 ReturnType, Context, Policy, Builder.getAllocator()));
9613 Builder.AddTextChunk(
"object");
9614 Results.AddResult(
Result(Builder.TakeString(), UnorderedGetterPriority,
9621 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9622 std::string SelectorName =
9623 (Twine(
"add") + UpperKey + Twine(
"Object")).str();
9625 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9626 if (ReturnType.
isNull()) {
9628 Builder.AddTextChunk(
"void");
9632 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9634 Builder.AddPlaceholderChunk(
"object-type");
9635 Builder.AddTextChunk(
" *");
9637 Builder.AddTextChunk(
"object");
9638 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9644 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9645 std::string SelectorName = (Twine(
"add") + UpperKey).str();
9647 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9648 if (ReturnType.
isNull()) {
9650 Builder.AddTextChunk(
"void");
9654 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9656 Builder.AddTextChunk(
"NSSet *");
9658 Builder.AddTextChunk(
"objects");
9659 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9665 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9666 std::string SelectorName =
9667 (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
9669 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9670 if (ReturnType.
isNull()) {
9672 Builder.AddTextChunk(
"void");
9676 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9678 Builder.AddPlaceholderChunk(
"object-type");
9679 Builder.AddTextChunk(
" *");
9681 Builder.AddTextChunk(
"object");
9682 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9688 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9689 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
9691 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9692 if (ReturnType.
isNull()) {
9694 Builder.AddTextChunk(
"void");
9698 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9700 Builder.AddTextChunk(
"NSSet *");
9702 Builder.AddTextChunk(
"objects");
9703 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9709 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
9710 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
9712 if (KnownSelectors.insert(Selectors.
getUnarySelector(SelectorId)).second) {
9713 if (ReturnType.
isNull()) {
9715 Builder.AddTextChunk(
"void");
9719 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName +
":"));
9721 Builder.AddTextChunk(
"NSSet *");
9723 Builder.AddTextChunk(
"objects");
9724 Results.AddResult(
Result(Builder.TakeString(), UnorderedSetterPriority,
9731 if (!IsInstanceMethod &&
9738 std::string SelectorName =
9739 (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
9743 if (ReturnType.
isNull()) {
9745 Builder.AddTextChunk(
"NSSet<NSString *> *");
9749 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9756 if (!IsInstanceMethod &&
9759 std::string SelectorName =
9760 (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
9764 if (ReturnType.
isNull()) {
9766 Builder.AddTextChunk(
"BOOL");
9770 Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName));
9778 Scope *S, std::optional<bool> IsInstanceMethod,
ParsedType ReturnTy) {
9783 Decl *IDecl =
nullptr;
9790 bool IsInImplementation =
false;
9791 if (
Decl *
D = IDecl) {
9793 SearchDecl = Impl->getClassInterface();
9794 IsInImplementation =
true;
9796 dyn_cast<ObjCCategoryImplDecl>(
D)) {
9797 SearchDecl = CatImpl->getCategoryDecl();
9798 IsInImplementation =
true;
9800 SearchDecl = dyn_cast<ObjCContainerDecl>(
D);
9803 if (!SearchDecl && S) {
9805 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
9821 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9822 CodeCompleter->getCodeCompletionTUInfo(),
9824 Results.EnterNewScope();
9826 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9827 MEnd = KnownMethods.end();
9831 Results.getCodeCompletionTUInfo());
9834 if (!IsInstanceMethod) {
9841 if (ReturnType.
isNull()) {
9852 Builder.AddTypedTextChunk(
9859 P != PEnd; (
void)++
P, ++I) {
9862 Builder.AddTypedTextChunk(
9866 Builder.AddTypedTextChunk(
9874 ParamType = (*P)->getType();
9876 ParamType = (*P)->getOriginalType();
9881 Context, Policy, Builder);
9884 Builder.AddTextChunk(
9885 Builder.getAllocator().CopyString(
Id->getName()));
9892 Builder.AddTextChunk(
"...");
9895 if (IsInImplementation && Results.includeCodePatterns()) {
9902 Builder.AddTextChunk(
"return");
9904 Builder.AddPlaceholderChunk(
"expression");
9907 Builder.AddPlaceholderChunk(
"statements");
9915 if (!M->second.getInt())
9917 Results.AddResult(std::move(R));
9924 Containers.push_back(SearchDecl);
9927 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
9928 MEnd = KnownMethods.end();
9930 KnownSelectors.insert(M->first);
9935 IFace =
Category->getClassInterface();
9940 if (IsInstanceMethod) {
9941 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
9942 for (
auto *
P : Containers[I]->instance_properties())
9944 KnownSelectors, Results);
9948 Results.ExitScope();
9951 Results.getCompletionContext(), Results.data(),
9956 Scope *S,
bool IsInstanceMethod,
bool AtParameterName,
ParsedType ReturnTy,
9961 for (uint32_t I = 0, N = SemaRef.
ExternalSource->GetNumExternalSelectors();
9973 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
9974 CodeCompleter->getCodeCompletionTUInfo(),
9978 Results.setPreferredType(
9981 Results.EnterNewScope();
9982 for (SemaObjC::GlobalMethodPool::iterator
9986 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first
9987 : &M->second.second;
9988 MethList && MethList->getMethod(); MethList = MethList->getNext()) {
9992 if (AtParameterName) {
9994 unsigned NumSelIdents = SelIdents.size();
9996 NumSelIdents <= MethList->getMethod()->param_size()) {
9998 MethList->getMethod()->parameters()[NumSelIdents - 1];
10001 Results.getCodeCompletionTUInfo());
10002 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
10004 Results.AddResult(Builder.TakeString());
10011 Result R(MethList->getMethod(),
10012 Results.getBasePriority(MethList->getMethod()),
nullptr);
10013 R.StartParameter = SelIdents.size();
10014 R.AllParametersAreInformative =
false;
10015 R.DeclaringEntity =
true;
10016 Results.MaybeAddResult(R, SemaRef.
CurContext);
10020 Results.ExitScope();
10022 if (!AtParameterName && !SelIdents.empty() &&
10023 SelIdents.front()->getName().starts_with(
"init")) {
10024 for (
const auto &M : SemaRef.
PP.
macros()) {
10025 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
10027 Results.EnterNewScope();
10029 Results.getCodeCompletionTUInfo());
10030 Builder.AddTypedTextChunk(
10031 Builder.getAllocator().CopyString(M.first->getName()));
10034 Results.ExitScope();
10039 Results.getCompletionContext(), Results.data(),
10044 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10045 CodeCompleter->getCodeCompletionTUInfo(),
10047 Results.EnterNewScope();
10051 Results.getCodeCompletionTUInfo());
10052 Builder.AddTypedTextChunk(
"if");
10054 Builder.AddPlaceholderChunk(
"condition");
10055 Results.AddResult(Builder.TakeString());
10058 Builder.AddTypedTextChunk(
"ifdef");
10060 Builder.AddPlaceholderChunk(
"macro");
10061 Results.AddResult(Builder.TakeString());
10064 Builder.AddTypedTextChunk(
"ifndef");
10066 Builder.AddPlaceholderChunk(
"macro");
10067 Results.AddResult(Builder.TakeString());
10069 if (InConditional) {
10071 Builder.AddTypedTextChunk(
"elif");
10073 Builder.AddPlaceholderChunk(
"condition");
10074 Results.AddResult(Builder.TakeString());
10077 Builder.AddTypedTextChunk(
"elifdef");
10079 Builder.AddPlaceholderChunk(
"macro");
10080 Results.AddResult(Builder.TakeString());
10083 Builder.AddTypedTextChunk(
"elifndef");
10085 Builder.AddPlaceholderChunk(
"macro");
10086 Results.AddResult(Builder.TakeString());
10089 Builder.AddTypedTextChunk(
"else");
10090 Results.AddResult(Builder.TakeString());
10093 Builder.AddTypedTextChunk(
"endif");
10094 Results.AddResult(Builder.TakeString());
10098 Builder.AddTypedTextChunk(
"include");
10100 Builder.AddTextChunk(
"\"");
10101 Builder.AddPlaceholderChunk(
"header");
10102 Builder.AddTextChunk(
"\"");
10103 Results.AddResult(Builder.TakeString());
10106 Builder.AddTypedTextChunk(
"include");
10108 Builder.AddTextChunk(
"<");
10109 Builder.AddPlaceholderChunk(
"header");
10110 Builder.AddTextChunk(
">");
10111 Results.AddResult(Builder.TakeString());
10114 Builder.AddTypedTextChunk(
"define");
10116 Builder.AddPlaceholderChunk(
"macro");
10117 Results.AddResult(Builder.TakeString());
10120 Builder.AddTypedTextChunk(
"define");
10122 Builder.AddPlaceholderChunk(
"macro");
10124 Builder.AddPlaceholderChunk(
"args");
10126 Results.AddResult(Builder.TakeString());
10129 Builder.AddTypedTextChunk(
"undef");
10131 Builder.AddPlaceholderChunk(
"macro");
10132 Results.AddResult(Builder.TakeString());
10135 Builder.AddTypedTextChunk(
"line");
10137 Builder.AddPlaceholderChunk(
"number");
10138 Results.AddResult(Builder.TakeString());
10141 Builder.AddTypedTextChunk(
"line");
10143 Builder.AddPlaceholderChunk(
"number");
10145 Builder.AddTextChunk(
"\"");
10146 Builder.AddPlaceholderChunk(
"filename");
10147 Builder.AddTextChunk(
"\"");
10148 Results.AddResult(Builder.TakeString());
10151 Builder.AddTypedTextChunk(
"error");
10153 Builder.AddPlaceholderChunk(
"message");
10154 Results.AddResult(Builder.TakeString());
10157 Builder.AddTypedTextChunk(
"pragma");
10159 Builder.AddPlaceholderChunk(
"arguments");
10160 Results.AddResult(Builder.TakeString());
10162 if (getLangOpts().
ObjC) {
10164 Builder.AddTypedTextChunk(
"import");
10166 Builder.AddTextChunk(
"\"");
10167 Builder.AddPlaceholderChunk(
"header");
10168 Builder.AddTextChunk(
"\"");
10169 Results.AddResult(Builder.TakeString());
10172 Builder.AddTypedTextChunk(
"import");
10174 Builder.AddTextChunk(
"<");
10175 Builder.AddPlaceholderChunk(
"header");
10176 Builder.AddTextChunk(
">");
10177 Results.AddResult(Builder.TakeString());
10181 Builder.AddTypedTextChunk(
"include_next");
10183 Builder.AddTextChunk(
"\"");
10184 Builder.AddPlaceholderChunk(
"header");
10185 Builder.AddTextChunk(
"\"");
10186 Results.AddResult(Builder.TakeString());
10189 Builder.AddTypedTextChunk(
"include_next");
10191 Builder.AddTextChunk(
"<");
10192 Builder.AddPlaceholderChunk(
"header");
10193 Builder.AddTextChunk(
">");
10194 Results.AddResult(Builder.TakeString());
10197 Builder.AddTypedTextChunk(
"warning");
10199 Builder.AddPlaceholderChunk(
"message");
10200 Results.AddResult(Builder.TakeString());
10207 Results.ExitScope();
10210 Results.getCompletionContext(), Results.data(),
10216 CodeCompleteOrdinaryName(S, S->getFnParent()
10222 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10223 CodeCompleter->getCodeCompletionTUInfo(),
10226 if (!IsDefinition && CodeCompleter->includeMacros()) {
10229 Results.getCodeCompletionTUInfo());
10230 Results.EnterNewScope();
10234 Builder.AddTypedTextChunk(
10235 Builder.getAllocator().CopyString(M->first->getName()));
10239 Results.ExitScope();
10240 }
else if (IsDefinition) {
10245 Results.getCompletionContext(), Results.data(),
10250 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10251 CodeCompleter->getCodeCompletionTUInfo(),
10254 if (CodeCompleter->includeMacros())
10258 Results.EnterNewScope();
10260 Results.getCodeCompletionTUInfo());
10261 Builder.AddTypedTextChunk(
"defined");
10264 Builder.AddPlaceholderChunk(
"macro");
10266 Results.AddResult(Builder.TakeString());
10267 Results.ExitScope();
10270 Results.getCompletionContext(), Results.data(),
10290 std::string RelDir = llvm::sys::path::convert_to_slash(Dir);
10293 llvm::sys::path::native(NativeRelDir);
10294 llvm::vfs::FileSystem &FS =
10297 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10298 CodeCompleter->getCodeCompletionTUInfo(),
10300 llvm::DenseSet<StringRef> SeenResults;
10303 auto AddCompletion = [&](StringRef
Filename,
bool IsDirectory) {
10306 TypedChunk.push_back(IsDirectory ?
'/' : Angled ?
'>' :
'"');
10307 auto R = SeenResults.insert(TypedChunk);
10309 const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
10310 *R.first = InternedTyped;
10312 CodeCompleter->getCodeCompletionTUInfo());
10313 Builder.AddTypedTextChunk(InternedTyped);
10321 auto AddFilesFromIncludeDir = [&](StringRef IncludeDir,
10325 if (!NativeRelDir.empty()) {
10329 auto Begin = llvm::sys::path::begin(NativeRelDir);
10330 auto End = llvm::sys::path::end(NativeRelDir);
10332 llvm::sys::path::append(Dir, *
Begin +
".framework",
"Headers");
10333 llvm::sys::path::append(Dir, ++
Begin, End);
10335 llvm::sys::path::append(Dir, NativeRelDir);
10339 const StringRef &Dirname = llvm::sys::path::filename(Dir);
10340 const bool isQt = Dirname.starts_with(
"Qt") || Dirname ==
"ActiveQt";
10341 const bool ExtensionlessHeaders =
10342 IsSystem || isQt || Dir.ends_with(
".framework/Headers");
10343 std::error_code EC;
10344 unsigned Count = 0;
10345 for (
auto It = FS.dir_begin(Dir, EC);
10346 !EC && It != llvm::vfs::directory_iterator(); It.increment(EC)) {
10347 if (++Count == 2500)
10349 StringRef
Filename = llvm::sys::path::filename(It->path());
10354 llvm::sys::fs::file_type
Type = It->type();
10355 if (
Type == llvm::sys::fs::file_type::symlink_file) {
10356 if (
auto FileStatus = FS.status(It->path()))
10357 Type = FileStatus->getType();
10360 case llvm::sys::fs::file_type::directory_file:
10364 NativeRelDir.empty() && !
Filename.consume_back(
".framework"))
10369 case llvm::sys::fs::file_type::regular_file: {
10371 const bool IsHeader =
Filename.ends_with_insensitive(
".h") ||
10372 Filename.ends_with_insensitive(
".hh") ||
10373 Filename.ends_with_insensitive(
".hpp") ||
10374 Filename.ends_with_insensitive(
".hxx") ||
10375 Filename.ends_with_insensitive(
".inc") ||
10376 (ExtensionlessHeaders && !
Filename.contains(
'.'));
10391 switch (IncludeDir.getLookupType()) {
10396 AddFilesFromIncludeDir(IncludeDir.getDirRef()->getName(), IsSystem,
10400 AddFilesFromIncludeDir(IncludeDir.getFrameworkDirRef()->getName(),
10410 using llvm::make_range;
10414 AddFilesFromIncludeDir(CurFile->getDir().getName(),
false,
10416 for (
const auto &
D : make_range(S.quoted_dir_begin(), S.quoted_dir_end()))
10417 AddFilesFromDirLookup(
D,
false);
10419 for (
const auto &
D : make_range(S.angled_dir_begin(), S.angled_dir_end()))
10420 AddFilesFromDirLookup(
D,
false);
10421 for (
const auto &
D : make_range(S.system_dir_begin(), S.system_dir_end()))
10422 AddFilesFromDirLookup(
D,
true);
10425 Results.getCompletionContext(), Results.data(),
10436 ResultBuilder Results(SemaRef, CodeCompleter->getAllocator(),
10437 CodeCompleter->getCodeCompletionTUInfo(),
10439 Results.EnterNewScope();
10440 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
10444 Twine(Platform) +
"ApplicationExtension")));
10446 Results.ExitScope();
10448 Results.getCompletionContext(), Results.data(),
10455 ResultBuilder Builder(SemaRef, Allocator, CCTUInfo,
10457 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
10458 CodeCompletionDeclConsumer Consumer(
10459 Builder, getASTContext().getTranslationUnitDecl());
10462 !CodeCompleter || CodeCompleter->loadExternal());
10465 if (!CodeCompleter || CodeCompleter->includeMacros())
10467 !CodeCompleter || CodeCompleter->loadExternal(),
true);
10470 Results.insert(Results.end(), Builder.data(),
10471 Builder.data() + Builder.size());
10476 :
SemaBase(S), CodeCompleter(CompletionConsumer) {}
This file provides AST data structures related to concepts.
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
enum clang::sema::@1714::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::@1325::AnnotatingParser::Context::@351 ContextType
C Language Family Type Representation.
pointer(const DeclIndexPair &Value)
const DeclIndexPair * operator->() const
pointer operator->() const
reference operator*() const
std::ptrdiff_t difference_type
friend bool operator!=(const iterator &X, const iterator &Y)
iterator(const NamedDecl *SingleDecl, unsigned Index)
std::input_iterator_tag iterator_category
iterator(const DeclIndexPair *Iterator)
friend bool operator==(const iterator &X, const iterator &Y)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
DeclarationNameTable DeclarationNames
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
SelectorTable & Selectors
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getElementType() const
Syntax
The style used to specify an attribute.
Type source information for an attributed type.
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Wrapper for source info for block pointers.
This class is used for builtin types like 'int'.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Represents a static or instance method of a struct/union/class.
overridden_method_range overridden_methods() const
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Qualifiers getMethodQualifiers() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
CXXRecordDecl * getDefinition() const
base_class_range vbases()
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Represents a C++ nested-name-specifier or a global scope specifier.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CaseStmt - Represent a case statement.
Represents a character-granular source range.
static CharSourceRange getTokenRange(SourceRange R)
Declaration of a class template.
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments, bool Braced) const
Create a new code-completion string that describes the function signature of this overload candidate.
const FunctionType * getFunctionType() const
Retrieve the function type of the entity, regardless of how the function is stored.
const TemplateDecl * getTemplate() const
CandidateKind getKind() const
Determine the kind of overload candidate.
const RecordDecl * getAggregate() const
Retrieve the aggregate type being initialized.
FunctionDecl * getFunction() const
Retrieve the function overload candidate or the templated function declaration for a function templat...
const FunctionProtoTypeLoc getFunctionProtoTypeLoc() const
Retrieve the function ProtoTypeLoc candidate.
@ CK_Aggregate
The candidate is aggregate initialization of a record type.
@ CK_Template
The candidate is a template, template arguments are being completed.
unsigned getNumParams() const
Get the number of parameters in this signature.
Abstract interface for a consumer of code-completion information.
bool includeGlobals() const
Whether to include global (top-level) declaration results.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
bool loadExternal() const
Hint whether to load data from the external AST in order to provide full results.
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates, SourceLocation OpenParLoc, bool Braced)
An allocator used specifically for the purpose of code completion.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
A builder class used to construct new code-completion strings.
CodeCompletionString * TakeString()
Take the resulting completion string.
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
void AddTextChunk(const char *Text)
Add a new text chunk.
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
The context in which code completion occurred, so that the code-completion consumer can process the r...
Kind getKind() const
Retrieve the kind of code-completion context.
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
@ CCC_TypeQualifiers
Code completion within a type-qualifier list.
@ CCC_ObjCMessageReceiver
Code completion occurred where an Objective-C message receiver is expected.
@ CCC_PreprocessorExpression
Code completion occurred within a preprocessor expression.
@ CCC_ObjCCategoryName
Code completion where an Objective-C category name is expected.
@ CCC_ObjCIvarList
Code completion occurred within the instance variable list of an Objective-C interface,...
@ CCC_Statement
Code completion occurred where a statement (or declaration) is expected in a function,...
@ CCC_Type
Code completion occurred where a type name is expected.
@ CCC_ArrowMemberAccess
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
@ CCC_ClassStructUnion
Code completion occurred within a class, struct, or union.
@ CCC_ObjCInterface
Code completion occurred within an Objective-C interface, protocol, or category interface.
@ CCC_ObjCPropertyAccess
Code completion occurred on the right-hand side of an Objective-C property access expression.
@ CCC_Expression
Code completion occurred where an expression is expected.
@ CCC_SelectorName
Code completion for a selector, as in an @selector expression.
@ CCC_TopLevelOrExpression
Code completion at a top level, i.e.
@ CCC_EnumTag
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
@ CCC_UnionTag
Code completion occurred after the "union" keyword, to indicate a union name.
@ CCC_ParenthesizedExpression
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
@ CCC_TopLevel
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope.
@ CCC_ClassOrStructTag
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name.
@ CCC_ObjCClassMessage
Code completion where an Objective-C class message is expected.
@ CCC_ObjCImplementation
Code completion occurred within an Objective-C implementation or category implementation.
@ CCC_IncludedFile
Code completion inside the filename part of a #include directive.
@ CCC_ObjCInstanceMessage
Code completion where an Objective-C instance message is expected.
@ CCC_SymbolOrNewName
Code completion occurred where both a new name and an existing symbol is permissible.
@ CCC_Recovery
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
@ CCC_ObjCProtocolName
Code completion occurred where a protocol name is expected.
@ CCC_NewName
Code completion occurred where a new name is expected.
@ CCC_MacroNameUse
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
@ CCC_Symbol
Code completion occurred where an existing name(such as type, function or variable) is expected.
@ CCC_Attribute
Code completion of an attribute name.
@ CCC_Other
An unspecified code-completion context.
@ CCC_DotMemberAccess
Code completion occurred on the right-hand side of a member access expression using the dot operator.
@ CCC_MacroName
Code completion occurred where an macro is being defined.
@ CCC_Namespace
Code completion occurred where a namespace or namespace alias is expected.
@ CCC_PreprocessorDirective
Code completion occurred where a preprocessor directive is expected.
@ CCC_NaturalLanguage
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
@ CCC_ObjCInterfaceName
Code completion where the name of an Objective-C class is expected.
@ CCC_ObjCClassForwardDecl
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
void setPreferredType(QualType T)
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
void setIsUsingDeclaration(bool V)
void addVisitedContext(DeclContext *Ctx)
Adds a visited context.
Captures a result of code completion.
bool DeclaringEntity
Whether we're completing a declaration of the given entity, rather than a use of that entity.
ResultKind Kind
The kind of result stored here.
const char * Keyword
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling.
CXAvailabilityKind Availability
The availability of this result.
NestedNameSpecifier * Qualifier
If the result should have a nested-name-specifier, this is it.
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program.
bool QualifierIsInformative
Whether this result was found via lookup into a base class.
const NamedDecl * Declaration
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to.
CodeCompletionString * createCodeCompletionStringForDecl(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
CodeCompletionString * CreateCodeCompletionStringForMacro(Preprocessor &PP, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo)
Creates a new code-completion string for the macro result.
unsigned StartParameter
Specifies which parameter (of a function, Objective-C method, macro, etc.) we should start with when ...
bool InBaseClass
Whether this is a class member from base class.
unsigned Priority
The priority of this particular code-completion result.
bool StartsNestedNameSpecifier
Whether this declaration is the beginning of a nested-name-specifier and, therefore,...
CodeCompletionString * Pattern
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert.
bool FunctionCanBeCall
When completing a function, whether it can be a call.
bool AllParametersAreInformative
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative".
CodeCompletionString * createCodeCompletionStringForOverride(Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy)
const IdentifierInfo * Macro
When Kind == RK_Macro, the identifier that refers to a macro.
@ RK_Pattern
Refers to a precomputed pattern.
@ RK_Declaration
Refers to a declaration.
@ RK_Macro
Refers to a macro.
@ RK_Keyword
Refers to a keyword or symbol.
A "string" used to describe how code completion can be performed for an entity.
@ CK_Optional
A code completion string that is entirely optional.
@ CK_CurrentParameter
A piece of text that describes the parameter that corresponds to the code-completion location within ...
@ CK_Comma
A comma separator (',').
@ CK_Placeholder
A string that acts as a placeholder for, e.g., a function call argument.
@ CK_LeftParen
A left parenthesis ('(').
@ CK_HorizontalSpace
Horizontal whitespace (' ').
@ CK_RightAngle
A right angle bracket ('>').
@ CK_LeftBracket
A left bracket ('[').
@ CK_RightParen
A right parenthesis (')').
@ CK_RightBrace
A right brace ('}').
@ CK_VerticalSpace
Vertical whitespace ('\n' or '\r\n', depending on the platform).
@ CK_SemiColon
A semicolon (';').
@ CK_TypedText
The piece of text that the user is expected to type to match the code-completion string,...
@ CK_RightBracket
A right bracket (']').
@ CK_LeftBrace
A left brace ('{').
@ CK_LeftAngle
A left angle bracket ('<').
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
const TypeClass * getTypePtr() const
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool 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_iterator decls_end() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
decl_iterator decls_begin() const
Captures information about "declaration specifiers".
static const TST TST_typename
TST getTypeSpecType() const
static const TST TST_interface
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static const TST TST_union
TSC getTypeSpecComplex() const
ParsedType getRepAsType() const
static const TST TST_enum
static const TST TST_class
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
bool isTypeAltiVecVector() const
TypeSpecifierSign getTypeSpecSign() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
@ FOK_Undeclared
A friend of a previously-undeclared entity.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
unsigned getIdentifierNamespace() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
@ IDNS_Member
Members, declared with object declarations within tag definitions.
@ IDNS_ObjCProtocol
Objective C @protocol.
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
@ IDNS_LocalExtern
This declaration is a function-local extern declaration of a variable or function.
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
TranslationUnitDecl * getTranslationUnitDecl()
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
uintptr_t getAsOpaqueInteger() const
Get the representation of this declaration name as an opaque integer.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
@ CXXConversionFunctionName
NameKind getNameKind() const
Determine what kind of name this is.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Represents a ValueDecl that came out of a declarator.
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
Represents a qualified type name for which the type name is dependent.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
A qualified reference to a name whose declaration cannot yet be resolved.
Designation - Represent a full designation, which is a sequence of designators.
const Designator & getDesignator(unsigned Idx) const
unsigned getNumDesignators() const
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
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
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...
@ 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.
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.
@ 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.
@ 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...
@ 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....
const FunctionProtoType * T
unsigned getMacroUsagePriority(StringRef MacroName, const LangOptions &LangOpts, bool PreferredTypeIsPointer=false)
Determine the priority to be given to a macro code completion result with the given name.
bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function)
llvm::StringRef getAsString(SyncScope S)
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ StartsWithDoubleUnderscore
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
bool IntegralConstantExpression
SmallVector< Decl *, 4 > IgnoreDecls
CodeCompleteExpressionData(QualType PreferredType=QualType(), bool IsParenthesized=false)
Represents a complete lambda introducer.
SmallVector< LambdaCapture, 4 > Captures
LambdaCaptureDefault Default
a linked list of methods with the same selector name but different signatures.
ObjCMethodDecl * getMethod() const
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
static ArrayRef< const ParsedAttrInfo * > getAllBuiltin()
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressUnwrittenScope
Suppress printing parts of scope specifiers that are never written, e.g., for anonymous namespaces.
unsigned AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g.,...
unsigned CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
unsigned SuppressScope
Suppresses printing of scope specifiers.
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.