28 #include "llvm/ADT/DenseSet.h" 29 #include "llvm/ADT/SmallBitVector.h" 30 #include "llvm/ADT/SmallPtrSet.h" 31 #include "llvm/ADT/SmallString.h" 32 #include "llvm/ADT/StringExtras.h" 33 #include "llvm/ADT/StringSwitch.h" 34 #include "llvm/ADT/Twine.h" 39 using namespace clang;
50 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
56 std::vector<Result> Results;
61 llvm::SmallPtrSet<const Decl*, 16> AllDeclsFound;
63 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
68 class ShadowMapEntry {
73 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector*> DeclOrVector;
77 unsigned SingleDeclIndex;
80 ShadowMapEntry() : DeclOrVector(), SingleDeclIndex(0) { }
82 void Add(
const NamedDecl *ND,
unsigned Index) {
83 if (DeclOrVector.isNull()) {
86 SingleDeclIndex = Index;
91 DeclOrVector.dyn_cast<
const NamedDecl *>()) {
94 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
95 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
100 DeclOrVector.get<DeclIndexPairVector*>()->push_back(
101 DeclIndexPair(ND, Index));
105 if (DeclIndexPairVector *Vec
106 = DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
114 iterator begin()
const;
115 iterator end()
const;
121 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
138 bool AllowNestedNameSpecifiers;
149 std::list<ShadowMap> ShadowMaps;
156 bool HasObjectTypeQualifiers;
168 void AdjustResultPriorityForDecl(Result &R);
170 void MaybeAddConstructorResults(Result R);
176 LookupFilter Filter =
nullptr)
177 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
179 AllowNestedNameSpecifiers(
false), HasObjectTypeQualifiers(
false),
180 CompletionContext(CompletionContext),
181 ObjCImplementation(nullptr)
185 switch (CompletionContext.
getKind()) {
192 if (Method->isInstanceMethod())
194 ObjCImplementation = Interface->getImplementation();
203 unsigned getBasePriority(
const NamedDecl *D);
207 bool includeCodePatterns()
const {
213 void setFilter(LookupFilter Filter) {
214 this->Filter = Filter;
217 Result *data() {
return Results.empty()? nullptr : &Results.front(); }
218 unsigned size()
const {
return Results.size(); }
219 bool empty()
const {
return Results.empty(); }
233 void setObjectTypeQualifiers(
Qualifiers Quals) {
234 ObjectTypeQualifiers = Quals;
235 HasObjectTypeQualifiers =
true;
243 void setPreferredSelector(
Selector Sel) {
244 PreferredSelector = Sel;
250 return CompletionContext;
254 void allowNestedNameSpecifiers(
bool Allow =
true) {
255 AllowNestedNameSpecifiers = Allow;
260 Sema &getSema()
const {
return SemaRef; }
274 bool isInterestingDecl(
const NamedDecl *ND,
275 bool &AsNestedNameSpecifier)
const;
283 bool CheckHiddenResult(Result &R,
DeclContext *CurContext,
293 void MaybeAddResult(Result R,
DeclContext *CurContext =
nullptr);
310 void AddResult(Result R);
313 void EnterNewScope();
327 bool IsOrdinaryName(
const NamedDecl *ND)
const;
328 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
329 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
330 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
331 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
333 bool IsClassOrStruct(
const NamedDecl *ND)
const;
335 bool IsNamespace(
const NamedDecl *ND)
const;
336 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
338 bool IsMember(
const NamedDecl *ND)
const;
339 bool IsObjCIvar(
const NamedDecl *ND)
const;
340 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
341 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
342 bool IsObjCCollection(
const NamedDecl *ND)
const;
343 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
349 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
350 unsigned SingleDeclIndex;
362 pointer(
const DeclIndexPair &Value) : Value(Value) { }
372 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) { }
375 : DeclOrIterator(Iterator), SingleDeclIndex(0) { }
378 if (DeclOrIterator.is<
const NamedDecl *>()) {
384 const DeclIndexPair *I = DeclOrIterator.get<
const DeclIndexPair*>();
398 return reference(ND, SingleDeclIndex);
400 return *DeclOrIterator.get<
const DeclIndexPair*>();
408 return X.DeclOrIterator.getOpaqueValue()
409 == Y.DeclOrIterator.getOpaqueValue() &&
410 X.SingleDeclIndex == Y.SingleDeclIndex;
419 ResultBuilder::ShadowMapEntry::begin()
const {
420 if (DeclOrVector.isNull())
424 return iterator(ND, SingleDeclIndex);
426 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin());
430 ResultBuilder::ShadowMapEntry::end()
const {
431 if (DeclOrVector.is<
const NamedDecl *>() || DeclOrVector.isNull())
434 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->end());
456 for (
const DeclContext *CommonAncestor = TargetContext;
457 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
458 CommonAncestor = CommonAncestor->getLookupParent()) {
459 if (CommonAncestor->isTransparentContext() ||
460 CommonAncestor->isFunctionOrMethod())
463 TargetParents.push_back(CommonAncestor);
467 while (!TargetParents.empty()) {
470 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
471 if (!Namespace->getIdentifier())
476 else if (
const TagDecl *TD = dyn_cast<TagDecl>(Parent))
487 bool doubleUnderscoreOnly =
false) {
491 return Name[0] ==
'_' &&
492 (Name[1] ==
'_' || (Name[1] >=
'A' && Name[1] <=
'Z' &&
493 !doubleUnderscoreOnly));
519 bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
520 bool &AsNestedNameSpecifier)
const {
521 AsNestedNameSpecifier =
false;
536 if (isa<ClassTemplateSpecializationDecl>(ND) ||
537 isa<ClassTemplatePartialSpecializationDecl>(ND))
541 if (isa<UsingDecl>(ND))
547 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
548 (isa<NamespaceDecl>(ND) &&
549 Filter != &ResultBuilder::IsNamespace &&
550 Filter != &ResultBuilder::IsNamespaceOrAlias &&
552 AsNestedNameSpecifier =
true;
555 if (Filter && !(this->*Filter)(Named)) {
557 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
558 IsNestedNameSpecifier(ND) &&
559 (Filter != &ResultBuilder::IsMember ||
560 (isa<CXXRecordDecl>(ND) &&
561 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
562 AsNestedNameSpecifier =
true;
572 bool ResultBuilder::CheckHiddenResult(Result &R,
DeclContext *CurContext,
592 R.QualifierIsInformative =
false;
597 R.Declaration->getDeclContext());
604 switch (T->getTypeClass()) {
606 switch (cast<BuiltinType>(T)->getKind()) {
607 case BuiltinType::Void:
610 case BuiltinType::NullPtr:
613 case BuiltinType::Overload:
614 case BuiltinType::Dependent:
617 case BuiltinType::ObjCId:
618 case BuiltinType::ObjCClass:
619 case BuiltinType::ObjCSel:
632 case Type::BlockPointer:
635 case Type::LValueReference:
636 case Type::RValueReference:
639 case Type::ConstantArray:
640 case Type::IncompleteArray:
641 case Type::VariableArray:
642 case Type::DependentSizedArray:
645 case Type::DependentSizedExtVector:
647 case Type::ExtVector:
650 case Type::FunctionProto:
651 case Type::FunctionNoProto:
660 case Type::ObjCObject:
661 case Type::ObjCInterface:
662 case Type::ObjCObjectPointer:
682 T = Function->getCallResultType();
683 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND))
684 T = Method->getSendResultType();
685 else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
690 T =
Value->getType();
704 if (Pointer->getPointeeType()->isFunctionType()) {
718 T = Function->getReturnType();
728 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
737 dyn_cast<ImplicitParamDecl>(ND))
738 if (ImplicitParam->getIdentifier() &&
739 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
746 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC)) {
748 if (isa<CXXDestructorDecl>(ND))
760 if (isa<EnumConstantDecl>(ND))
766 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
777 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
780 if (!PreferredSelector.
isNull())
781 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
782 if (PreferredSelector == Method->getSelector())
797 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
803 void ResultBuilder::MaybeAddConstructorResults(Result R) {
804 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
812 Record = ClassTemplate->getTemplatedDecl();
813 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
815 if (isa<ClassTemplateSpecializationDecl>(Record))
837 Results.push_back(R);
841 void ResultBuilder::MaybeAddResult(Result R,
DeclContext *CurContext) {
842 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
844 if (R.Kind != Result::RK_Declaration) {
846 Results.push_back(R);
852 dyn_cast<UsingShadowDecl>(R.Declaration)) {
853 MaybeAddResult(Result(Using->getTargetDecl(),
854 getBasePriority(Using->getTargetDecl()),
863 bool AsNestedNameSpecifier =
false;
864 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
868 if (isa<CXXConstructorDecl>(R.Declaration))
871 ShadowMap &
SMap = ShadowMaps.back();
872 ShadowMapEntry::iterator I, IEnd;
873 ShadowMap::iterator NamePos = SMap.find(R.Declaration->getDeclName());
874 if (NamePos != SMap.end()) {
875 I = NamePos->second.begin();
876 IEnd = NamePos->second.end();
879 for (; I != IEnd; ++I) {
881 unsigned Index = I->second;
884 Results[Index].Declaration = R.Declaration;
894 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
896 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
897 ShadowMapEntry::iterator I, IEnd;
898 ShadowMap::iterator NamePos = SM->find(R.Declaration->getDeclName());
899 if (NamePos != SM->end()) {
900 I = NamePos->second.begin();
901 IEnd = NamePos->second.end();
903 for (; I != IEnd; ++I) {
905 if (I->first->hasTagIdentifierNamespace() &&
913 I->first->getIdentifierNamespace() != IDNS)
917 if (CheckHiddenResult(R, CurContext, I->first))
925 if (!AllDeclsFound.insert(CanonDecl).second)
930 if (AsNestedNameSpecifier) {
931 R.StartsNestedNameSpecifier =
true;
934 AdjustResultPriorityForDecl(R);
937 if (R.QualifierIsInformative && !R.Qualifier &&
938 !R.StartsNestedNameSpecifier) {
939 const DeclContext *Ctx = R.Declaration->getDeclContext();
940 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
943 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
947 R.QualifierIsInformative =
false;
952 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
953 Results.push_back(R);
955 if (!AsNestedNameSpecifier)
956 MaybeAddConstructorResults(R);
959 void ResultBuilder::AddResult(Result R,
DeclContext *CurContext,
960 NamedDecl *Hiding,
bool InBaseClass =
false) {
961 if (R.Kind != Result::RK_Declaration) {
963 Results.push_back(R);
968 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
969 AddResult(Result(Using->getTargetDecl(),
970 getBasePriority(Using->getTargetDecl()),
976 bool AsNestedNameSpecifier =
false;
977 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
981 if (isa<CXXConstructorDecl>(R.Declaration))
984 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
988 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
993 if (AsNestedNameSpecifier) {
994 R.StartsNestedNameSpecifier =
true;
997 else if (Filter == &ResultBuilder::IsMember && !R.Qualifier && InBaseClass &&
998 isa<CXXRecordDecl>(R.Declaration->getDeclContext()
999 ->getRedeclContext()))
1000 R.QualifierIsInformative =
true;
1003 if (R.QualifierIsInformative && !R.Qualifier &&
1004 !R.StartsNestedNameSpecifier) {
1005 const DeclContext *Ctx = R.Declaration->getDeclContext();
1006 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
1009 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1013 R.QualifierIsInformative =
false;
1020 AdjustResultPriorityForDecl(R);
1022 if (HasObjectTypeQualifiers)
1023 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1024 if (Method->isInstance()) {
1027 if (ObjectTypeQualifiers == MethodQuals)
1029 else if (ObjectTypeQualifiers - MethodQuals) {
1037 Results.push_back(R);
1039 if (!AsNestedNameSpecifier)
1040 MaybeAddConstructorResults(R);
1043 void ResultBuilder::AddResult(Result R) {
1044 assert(R.Kind != Result::RK_Declaration &&
1045 "Declaration results need more context");
1046 Results.push_back(R);
1050 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1053 void ResultBuilder::ExitScope() {
1054 for (ShadowMap::iterator E = ShadowMaps.back().begin(),
1055 EEnd = ShadowMaps.back().end();
1058 E->second.Destroy();
1060 ShadowMaps.pop_back();
1065 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1074 if (isa<ObjCIvarDecl>(ND))
1083 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1085 if (isa<TypeDecl>(ND))
1090 if (
const auto *
ID = dyn_cast<ObjCInterfaceDecl>(ND)) {
1091 if (!
ID->getDefinition())
1099 if (isa<ObjCIvarDecl>(ND))
1106 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1107 if (!IsOrdinaryNonTypeName(ND))
1111 if (VD->getType()->isIntegralOrEnumerationType())
1119 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1127 !isa<ValueDecl>(ND) && !isa<FunctionTemplateDecl>(ND) &&
1128 !isa<ObjCPropertyDecl>(ND);
1133 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1136 ND = ClassTemplate->getTemplatedDecl();
1142 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1143 return isa<EnumDecl>(ND);
1147 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1150 ND = ClassTemplate->getTemplatedDecl();
1153 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1162 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1165 ND = ClassTemplate->getTemplatedDecl();
1167 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1174 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1175 return isa<NamespaceDecl>(ND);
1180 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1185 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1187 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1193 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1195 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1196 isa<ObjCPropertyDecl>(ND);
1202 case Type::ObjCObject:
1203 case Type::ObjCInterface:
1204 case Type::ObjCObjectPointer:
1208 switch (cast<BuiltinType>(T)->getKind()) {
1209 case BuiltinType::ObjCId:
1210 case BuiltinType::ObjCClass:
1211 case BuiltinType::ObjCSel:
1232 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1241 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const {
1242 if (IsObjCMessageReceiver(ND))
1252 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1253 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1254 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1267 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1273 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1274 return isa<ObjCIvarDecl>(ND);
1281 ResultBuilder &Results;
1285 CodeCompletionDeclConsumer(ResultBuilder &Results,
DeclContext *CurContext)
1286 : Results(Results), CurContext(CurContext) { }
1289 bool InBaseClass)
override {
1290 bool Accessible =
true;
1292 Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx);
1296 Results.AddResult(Result, CurContext, Hiding, InBaseClass);
1303 ResultBuilder &Results) {
1305 Results.AddResult(Result(
"short",
CCP_Type));
1306 Results.AddResult(Result(
"long",
CCP_Type));
1307 Results.AddResult(Result(
"signed",
CCP_Type));
1308 Results.AddResult(Result(
"unsigned",
CCP_Type));
1309 Results.AddResult(Result(
"void",
CCP_Type));
1310 Results.AddResult(Result(
"char",
CCP_Type));
1311 Results.AddResult(Result(
"int",
CCP_Type));
1312 Results.AddResult(Result(
"float",
CCP_Type));
1313 Results.AddResult(Result(
"double",
CCP_Type));
1314 Results.AddResult(Result(
"enum",
CCP_Type));
1315 Results.AddResult(Result(
"struct",
CCP_Type));
1316 Results.AddResult(Result(
"union",
CCP_Type));
1317 Results.AddResult(Result(
"const",
CCP_Type));
1318 Results.AddResult(Result(
"volatile",
CCP_Type));
1322 Results.AddResult(Result(
"_Complex",
CCP_Type));
1323 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1324 Results.AddResult(Result(
"_Bool",
CCP_Type));
1325 Results.AddResult(Result(
"restrict",
CCP_Type));
1329 Results.getCodeCompletionTUInfo());
1330 if (LangOpts.CPlusPlus) {
1332 Results.AddResult(Result(
"bool",
CCP_Type +
1334 Results.AddResult(Result(
"class",
CCP_Type));
1335 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1338 Builder.AddTypedTextChunk(
"typename");
1340 Builder.AddPlaceholderChunk(
"qualifier");
1341 Builder.AddTextChunk(
"::");
1342 Builder.AddPlaceholderChunk(
"name");
1343 Results.AddResult(Result(Builder.TakeString()));
1345 if (LangOpts.CPlusPlus11) {
1346 Results.AddResult(Result(
"auto",
CCP_Type));
1347 Results.AddResult(Result(
"char16_t",
CCP_Type));
1348 Results.AddResult(Result(
"char32_t",
CCP_Type));
1350 Builder.AddTypedTextChunk(
"decltype");
1352 Builder.AddPlaceholderChunk(
"expression");
1354 Results.AddResult(Result(Builder.TakeString()));
1357 Results.AddResult(Result(
"__auto_type",
CCP_Type));
1360 if (LangOpts.GNUMode) {
1366 Builder.AddTypedTextChunk(
"typeof");
1368 Builder.AddPlaceholderChunk(
"expression");
1369 Results.AddResult(Result(Builder.TakeString()));
1371 Builder.AddTypedTextChunk(
"typeof");
1373 Builder.AddPlaceholderChunk(
"type");
1375 Results.AddResult(Result(Builder.TakeString()));
1379 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1380 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1381 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1386 ResultBuilder &Results) {
1391 Results.AddResult(Result(
"extern"));
1392 Results.AddResult(Result(
"static"));
1394 if (LangOpts.CPlusPlus11) {
1399 Builder.AddTypedTextChunk(
"alignas");
1401 Builder.AddPlaceholderChunk(
"expression");
1403 Results.AddResult(Result(Builder.TakeString()));
1405 Results.AddResult(Result(
"constexpr"));
1406 Results.AddResult(Result(
"thread_local"));
1412 ResultBuilder &Results) {
1417 if (LangOpts.CPlusPlus) {
1418 Results.AddResult(Result(
"explicit"));
1419 Results.AddResult(Result(
"friend"));
1420 Results.AddResult(Result(
"mutable"));
1421 Results.AddResult(Result(
"virtual"));
1429 if (LangOpts.CPlusPlus || LangOpts.C99)
1430 Results.AddResult(Result(
"inline"));
1449 ResultBuilder &Results,
1452 ResultBuilder &Results,
1455 ResultBuilder &Results,
1461 Results.getCodeCompletionTUInfo());
1462 Builder.AddTypedTextChunk(
"typedef");
1464 Builder.AddPlaceholderChunk(
"type");
1466 Builder.AddPlaceholderChunk(
"name");
1487 return LangOpts.CPlusPlus;
1494 return LangOpts.CPlusPlus || LangOpts.ObjC1 || LangOpts.C99;
1497 llvm_unreachable(
"Invalid ParserCompletionContext!");
1526 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1527 return BT->getNameAsCString(Policy);
1530 if (
const TagType *TagT = dyn_cast<TagType>(T))
1531 if (
TagDecl *Tag = TagT->getDecl())
1532 if (!Tag->hasNameForLinkage()) {
1533 switch (Tag->getTagKind()) {
1534 case TTK_Struct:
return "struct <anonymous>";
1536 case TTK_Class:
return "class <anonymous>";
1537 case TTK_Union:
return "union <anonymous>";
1538 case TTK_Enum:
return "enum <anonymous>";
1562 Builder.AddTypedTextChunk(
"this");
1567 ResultBuilder &Results,
1569 if (!LangOpts.CPlusPlus11)
1585 ResultBuilder &Results) {
1593 if (Results.includeCodePatterns()) {
1595 Builder.AddTypedTextChunk(
"namespace");
1597 Builder.AddPlaceholderChunk(
"identifier");
1599 Builder.AddPlaceholderChunk(
"declarations");
1602 Results.AddResult(Result(Builder.TakeString()));
1606 Builder.AddTypedTextChunk(
"namespace");
1608 Builder.AddPlaceholderChunk(
"name");
1610 Builder.AddPlaceholderChunk(
"namespace");
1611 Results.AddResult(Result(Builder.TakeString()));
1614 Builder.AddTypedTextChunk(
"using");
1616 Builder.AddTextChunk(
"namespace");
1618 Builder.AddPlaceholderChunk(
"identifier");
1619 Results.AddResult(Result(Builder.TakeString()));
1622 Builder.AddTypedTextChunk(
"asm");
1624 Builder.AddPlaceholderChunk(
"string-literal");
1626 Results.AddResult(Result(Builder.TakeString()));
1628 if (Results.includeCodePatterns()) {
1630 Builder.AddTypedTextChunk(
"template");
1632 Builder.AddPlaceholderChunk(
"declaration");
1633 Results.AddResult(Result(Builder.TakeString()));
1646 Builder.AddTypedTextChunk(
"using");
1648 Builder.AddPlaceholderChunk(
"qualifier");
1649 Builder.AddTextChunk(
"::");
1650 Builder.AddPlaceholderChunk(
"name");
1651 Results.AddResult(Result(Builder.TakeString()));
1655 Builder.AddTypedTextChunk(
"using");
1657 Builder.AddTextChunk(
"typename");
1659 Builder.AddPlaceholderChunk(
"qualifier");
1660 Builder.AddTextChunk(
"::");
1661 Builder.AddPlaceholderChunk(
"name");
1662 Results.AddResult(Result(Builder.TakeString()));
1670 bool IsNotInheritanceScope =
1673 Builder.AddTypedTextChunk(
"public");
1674 if (IsNotInheritanceScope && Results.includeCodePatterns())
1676 Results.AddResult(Result(Builder.TakeString()));
1679 Builder.AddTypedTextChunk(
"protected");
1680 if (IsNotInheritanceScope && Results.includeCodePatterns())
1682 Results.AddResult(Result(Builder.TakeString()));
1685 Builder.AddTypedTextChunk(
"private");
1686 if (IsNotInheritanceScope && Results.includeCodePatterns())
1688 Results.AddResult(Result(Builder.TakeString()));
1695 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
1697 Builder.AddTypedTextChunk(
"template");
1699 Builder.AddPlaceholderChunk(
"parameters");
1701 Results.AddResult(Result(Builder.TakeString()));
1728 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
1730 Builder.AddTypedTextChunk(
"try");
1732 Builder.AddPlaceholderChunk(
"statements");
1735 Builder.AddTextChunk(
"catch");
1737 Builder.AddPlaceholderChunk(
"declaration");
1740 Builder.AddPlaceholderChunk(
"statements");
1743 Results.AddResult(Result(Builder.TakeString()));
1748 if (Results.includeCodePatterns()) {
1750 Builder.AddTypedTextChunk(
"if");
1753 Builder.AddPlaceholderChunk(
"condition");
1755 Builder.AddPlaceholderChunk(
"expression");
1758 Builder.AddPlaceholderChunk(
"statements");
1761 Results.AddResult(Result(Builder.TakeString()));
1764 Builder.AddTypedTextChunk(
"switch");
1767 Builder.AddPlaceholderChunk(
"condition");
1769 Builder.AddPlaceholderChunk(
"expression");
1774 Results.AddResult(Result(Builder.TakeString()));
1780 Builder.AddTypedTextChunk(
"case");
1782 Builder.AddPlaceholderChunk(
"expression");
1784 Results.AddResult(Result(Builder.TakeString()));
1787 Builder.AddTypedTextChunk(
"default");
1789 Results.AddResult(Result(Builder.TakeString()));
1792 if (Results.includeCodePatterns()) {
1794 Builder.AddTypedTextChunk(
"while");
1797 Builder.AddPlaceholderChunk(
"condition");
1799 Builder.AddPlaceholderChunk(
"expression");
1802 Builder.AddPlaceholderChunk(
"statements");
1805 Results.AddResult(Result(Builder.TakeString()));
1808 Builder.AddTypedTextChunk(
"do");
1810 Builder.AddPlaceholderChunk(
"statements");
1813 Builder.AddTextChunk(
"while");
1815 Builder.AddPlaceholderChunk(
"expression");
1817 Results.AddResult(Result(Builder.TakeString()));
1820 Builder.AddTypedTextChunk(
"for");
1823 Builder.AddPlaceholderChunk(
"init-statement");
1825 Builder.AddPlaceholderChunk(
"init-expression");
1827 Builder.AddPlaceholderChunk(
"condition");
1829 Builder.AddPlaceholderChunk(
"inc-expression");
1833 Builder.AddPlaceholderChunk(
"statements");
1836 Results.AddResult(Result(Builder.TakeString()));
1841 Builder.AddTypedTextChunk(
"continue");
1842 Results.AddResult(Result(Builder.TakeString()));
1847 Builder.AddTypedTextChunk(
"break");
1848 Results.AddResult(Result(Builder.TakeString()));
1853 bool isVoid =
false;
1855 isVoid = Function->getReturnType()->isVoidType();
1857 = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
1858 isVoid = Method->getReturnType()->isVoidType();
1862 Builder.AddTypedTextChunk(
"return");
1865 Builder.AddPlaceholderChunk(
"expression");
1867 Results.AddResult(Result(Builder.TakeString()));
1870 Builder.AddTypedTextChunk(
"goto");
1872 Builder.AddPlaceholderChunk(
"label");
1873 Results.AddResult(Result(Builder.TakeString()));
1876 Builder.AddTypedTextChunk(
"using");
1878 Builder.AddTextChunk(
"namespace");
1880 Builder.AddPlaceholderChunk(
"identifier");
1881 Results.AddResult(Result(Builder.TakeString()));
1898 Builder.AddTypedTextChunk(
"__bridge");
1900 Builder.AddPlaceholderChunk(
"type");
1902 Builder.AddPlaceholderChunk(
"expression");
1903 Results.AddResult(Result(Builder.TakeString()));
1906 Builder.AddTypedTextChunk(
"__bridge_transfer");
1908 Builder.AddPlaceholderChunk(
"Objective-C type");
1910 Builder.AddPlaceholderChunk(
"expression");
1911 Results.AddResult(Result(Builder.TakeString()));
1914 Builder.AddTypedTextChunk(
"__bridge_retained");
1916 Builder.AddPlaceholderChunk(
"CF type");
1918 Builder.AddPlaceholderChunk(
"expression");
1919 Results.AddResult(Result(Builder.TakeString()));
1930 Builder.AddResultTypeChunk(
"bool");
1931 Builder.AddTypedTextChunk(
"true");
1932 Results.AddResult(Result(Builder.TakeString()));
1935 Builder.AddResultTypeChunk(
"bool");
1936 Builder.AddTypedTextChunk(
"false");
1937 Results.AddResult(Result(Builder.TakeString()));
1941 Builder.AddTypedTextChunk(
"dynamic_cast");
1943 Builder.AddPlaceholderChunk(
"type");
1946 Builder.AddPlaceholderChunk(
"expression");
1948 Results.AddResult(Result(Builder.TakeString()));
1952 Builder.AddTypedTextChunk(
"static_cast");
1954 Builder.AddPlaceholderChunk(
"type");
1957 Builder.AddPlaceholderChunk(
"expression");
1959 Results.AddResult(Result(Builder.TakeString()));
1962 Builder.AddTypedTextChunk(
"reinterpret_cast");
1964 Builder.AddPlaceholderChunk(
"type");
1967 Builder.AddPlaceholderChunk(
"expression");
1969 Results.AddResult(Result(Builder.TakeString()));
1972 Builder.AddTypedTextChunk(
"const_cast");
1974 Builder.AddPlaceholderChunk(
"type");
1977 Builder.AddPlaceholderChunk(
"expression");
1979 Results.AddResult(Result(Builder.TakeString()));
1983 Builder.AddResultTypeChunk(
"std::type_info");
1984 Builder.AddTypedTextChunk(
"typeid");
1986 Builder.AddPlaceholderChunk(
"expression-or-type");
1988 Results.AddResult(Result(Builder.TakeString()));
1992 Builder.AddTypedTextChunk(
"new");
1994 Builder.AddPlaceholderChunk(
"type");
1996 Builder.AddPlaceholderChunk(
"expressions");
1998 Results.AddResult(Result(Builder.TakeString()));
2001 Builder.AddTypedTextChunk(
"new");
2003 Builder.AddPlaceholderChunk(
"type");
2005 Builder.AddPlaceholderChunk(
"size");
2008 Builder.AddPlaceholderChunk(
"expressions");
2010 Results.AddResult(Result(Builder.TakeString()));
2013 Builder.AddResultTypeChunk(
"void");
2014 Builder.AddTypedTextChunk(
"delete");
2016 Builder.AddPlaceholderChunk(
"expression");
2017 Results.AddResult(Result(Builder.TakeString()));
2020 Builder.AddResultTypeChunk(
"void");
2021 Builder.AddTypedTextChunk(
"delete");
2026 Builder.AddPlaceholderChunk(
"expression");
2027 Results.AddResult(Result(Builder.TakeString()));
2031 Builder.AddResultTypeChunk(
"void");
2032 Builder.AddTypedTextChunk(
"throw");
2034 Builder.AddPlaceholderChunk(
"expression");
2035 Results.AddResult(Result(Builder.TakeString()));
2042 Builder.AddResultTypeChunk(
"std::nullptr_t");
2043 Builder.AddTypedTextChunk(
"nullptr");
2044 Results.AddResult(Result(Builder.TakeString()));
2047 Builder.AddResultTypeChunk(
"size_t");
2048 Builder.AddTypedTextChunk(
"alignof");
2050 Builder.AddPlaceholderChunk(
"type");
2052 Results.AddResult(Result(Builder.TakeString()));
2055 Builder.AddResultTypeChunk(
"bool");
2056 Builder.AddTypedTextChunk(
"noexcept");
2058 Builder.AddPlaceholderChunk(
"expression");
2060 Results.AddResult(Result(Builder.TakeString()));
2063 Builder.AddResultTypeChunk(
"size_t");
2064 Builder.AddTypedTextChunk(
"sizeof...");
2066 Builder.AddPlaceholderChunk(
"parameter-pack");
2068 Results.AddResult(Result(Builder.TakeString()));
2077 if (
ID->getSuperClass()) {
2078 std::string SuperType;
2079 SuperType =
ID->getSuperClass()->getNameAsString();
2080 if (Method->isInstanceMethod())
2083 Builder.AddResultTypeChunk(Allocator.
CopyString(SuperType));
2084 Builder.AddTypedTextChunk(
"super");
2085 Results.AddResult(Result(Builder.TakeString()));
2094 Builder.AddResultTypeChunk(
"size_t");
2096 Builder.AddTypedTextChunk(
"alignof");
2098 Builder.AddTypedTextChunk(
"_Alignof");
2100 Builder.AddPlaceholderChunk(
"type");
2102 Results.AddResult(Result(Builder.TakeString()));
2106 Builder.AddResultTypeChunk(
"size_t");
2107 Builder.AddTypedTextChunk(
"sizeof");
2109 Builder.AddPlaceholderChunk(
"expression-or-type");
2111 Results.AddResult(Result(Builder.TakeString()));
2124 Results.AddResult(Result(
"operator"));
2139 if (isa<CXXConstructorDecl>(ND) || isa<CXXConversionDecl>(ND))
2145 T = Function->getReturnType();
2146 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2148 T = Method->getSendResultType(BaseType);
2150 T = Method->getReturnType();
2151 }
else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND)) {
2152 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2154 }
else if (isa<UnresolvedUsingValueDecl>(ND)) {
2156 }
else if (
const ObjCIvarDecl *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2158 T = Ivar->getUsageType(BaseType);
2160 T = Ivar->getType();
2162 T =
Value->getType();
2165 T =
Property->getUsageType(BaseType);
2180 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2181 if (Sentinel->getSentinel() == 0) {
2201 Result +=
"bycopy ";
2205 Result +=
"oneway ";
2208 switch (*nullability) {
2210 Result +=
"nonnull ";
2214 Result +=
"nullable ";
2218 Result +=
"null_unspecified ";
2235 bool SuppressBlock =
false) {
2241 if (!SuppressBlock) {
2244 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2257 TL = AttrTL.getModifiedLoc();
2276 bool SuppressBlockName =
false,
2277 bool SuppressBlock =
false,
2278 Optional<ArrayRef<QualType>> ObjCSubsts = None);
2282 bool SuppressName =
false,
2283 bool SuppressBlock =
false,
2284 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2285 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2292 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2299 if (ObjCMethodParam) {
2319 if (!Block && ObjCMethodParam &&
2320 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
2321 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
2322 ->findPropertyDecl(
false))
2336 if (ObjCMethodParam) {
2341 Result =
"(" + Quals +
" " + Result +
")";
2342 if (Result.back() !=
')')
2356 false, SuppressBlock,
2372 bool SuppressBlockName,
bool SuppressBlock,
2373 Optional<ArrayRef<QualType>> ObjCSubsts) {
2380 if (!ResultType->
isVoidType() || SuppressBlock)
2392 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++I) {
2405 if (SuppressBlock) {
2407 Result = Result +
" (^";
2414 Result =
'^' + Result;
2429 bool Invalid = CharSrcRange.
isInvalid();
2436 if (srcText.empty() || srcText ==
"=") {
2441 std::string DefValue(srcText.str());
2444 if (DefValue.at(0) !=
'=') {
2447 return " = " + DefValue;
2449 return " " + DefValue;
2458 bool InOptional =
false) {
2459 bool FirstParameter =
true;
2469 if (!FirstParameter)
2477 FirstParameter =
false;
2489 PlaceholderStr +=
", ...";
2498 if (Proto->isVariadic()) {
2499 if (Proto->getNumParams() == 0)
2511 unsigned MaxParameters = 0,
2513 bool InDefaultArg =
false) {
2514 bool FirstParameter =
true;
2523 PEnd = Params->begin() + MaxParameters;
2526 bool HasDefaultArg =
false;
2527 std::string PlaceholderStr;
2529 if (TTP->wasDeclaredWithTypename())
2530 PlaceholderStr =
"typename";
2532 PlaceholderStr =
"class";
2534 if (TTP->getIdentifier()) {
2535 PlaceholderStr +=
' ';
2539 HasDefaultArg = TTP->hasDefaultArgument();
2541 = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
2542 if (NTTP->getIdentifier())
2543 PlaceholderStr = NTTP->getIdentifier()->getName();
2544 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
2545 HasDefaultArg = NTTP->hasDefaultArgument();
2547 assert(isa<TemplateTemplateParmDecl>(*
P));
2552 PlaceholderStr =
"template<...> class";
2554 PlaceholderStr +=
' ';
2561 if (HasDefaultArg && !InDefaultArg) {
2566 if (!FirstParameter)
2569 P - Params->begin(),
true);
2574 InDefaultArg =
false;
2577 FirstParameter =
false;
2592 bool QualifierIsInformative,
2598 std::string PrintedNNS;
2600 llvm::raw_string_ostream OS(PrintedNNS);
2601 Qualifier->
print(OS, Policy);
2603 if (QualifierIsInformative)
2636 std::string QualsStr;
2638 QualsStr +=
" const";
2640 QualsStr +=
" volatile";
2642 QualsStr +=
" restrict";
2656 const char *OperatorName =
nullptr;
2659 case OO_Conditional:
2661 OperatorName =
"operator";
2664 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 2665 case OO_##Name: OperatorName = "operator" Spelling; break; 2666 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly) 2667 #include "clang/Basic/OperatorKinds.def" 2669 case OO_New: OperatorName =
"operator new";
break;
2670 case OO_Delete: OperatorName =
"operator delete";
break;
2671 case OO_Array_New: OperatorName =
"operator new[]";
break;
2672 case OO_Array_Delete: OperatorName =
"operator delete[]";
break;
2673 case OO_Call: OperatorName =
"operator()";
break;
2674 case OO_Subscript: OperatorName =
"operator[]";
break;
2699 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
2702 Record = InjectedTy->getDecl();
2725 bool IncludeBriefComments) {
2726 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
2727 CCTUInfo, IncludeBriefComments);
2742 bool IncludeBriefComments) {
2746 if (
Kind == RK_Pattern) {
2747 Pattern->Priority = Priority;
2748 Pattern->Availability = Availability;
2759 if (M->isPropertyAccessor())
2761 if (PDecl->getGetterName() == M->getSelector() &&
2762 PDecl->getIdentifier() != M->getIdentifier()) {
2779 if (
Kind == RK_Keyword) {
2784 if (
Kind == RK_Macro) {
2827 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
2831 if (IncludeBriefComments) {
2836 else if (
const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
2837 if (OMD->isPropertyAccessor())
2843 if (StartsNestedNameSpecifier) {
2855 if (
const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
2874 llvm::SmallBitVector Deduced;
2876 unsigned LastDeducibleArgument;
2877 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
2878 --LastDeducibleArgument) {
2879 if (!Deduced[LastDeducibleArgument - 1]) {
2883 bool HasDefaultArg =
false;
2884 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
2885 LastDeducibleArgument - 1);
2887 HasDefaultArg = TTP->hasDefaultArgument();
2889 = dyn_cast<NonTypeTemplateParmDecl>(Param))
2890 HasDefaultArg = NTTP->hasDefaultArgument();
2892 assert(isa<TemplateTemplateParmDecl>(Param));
2894 = cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
2902 if (LastDeducibleArgument) {
2908 LastDeducibleArgument);
2920 if (
const TemplateDecl *Template = dyn_cast<TemplateDecl>(ND)) {
2931 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2932 Selector Sel = Method->getSelector();
2941 if (StartParameter == 0)
2948 if (Method->param_size() == 1)
2953 PEnd = Method->param_end();
2954 P != PEnd; (void)++
P, ++Idx) {
2956 std::string Keyword;
2957 if (Idx > StartParameter)
2960 Keyword += II->getName();
2962 if (Idx < StartParameter || AllParametersAreInformative)
2969 if (Idx < StartParameter)
2973 QualType ParamType = (*P)->getType();
2990 if (DeclaringEntity || AllParametersAreInformative)
2991 Arg += II->getName();
2994 if (Method->isVariadic() && (
P + 1) == PEnd)
2997 if (DeclaringEntity)
2999 else if (AllParametersAreInformative)
3005 if (Method->isVariadic()) {
3006 if (Method->param_size() == 0) {
3007 if (DeclaringEntity)
3009 else if (AllParametersAreInformative)
3037 unsigned CurrentArg,
3039 bool InOptional =
false) {
3040 bool FirstParameter =
true;
3041 unsigned NumParams = Function ? Function->
getNumParams()
3044 for (
unsigned P = Start;
P != NumParams; ++
P) {
3050 if (!FirstParameter)
3054 CurrentArg,
P,
true);
3060 FirstParameter =
false;
3067 std::string Placeholder;
3077 if (
P == CurrentArg)
3087 if (!FirstParameter)
3090 if (CurrentArg < NumParams)
3091 Opt.AddPlaceholderChunk(
"...");
3093 Opt.AddCurrentParameterChunk(
"...");
3101 unsigned CurrentArg,
Sema &S,
3104 bool IncludeBriefComments)
const {
3112 if (!FDecl && !Proto) {
3125 if (IncludeBriefComments && CurrentArg < FDecl->getNumParams())
3143 return Result.TakeString();
3148 bool PreferredTypeIsPointer) {
3152 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
3153 MacroName.equals(
"Nil")) {
3155 if (PreferredTypeIsPointer)
3159 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
3160 MacroName.equals(
"true") || MacroName.equals(
"false"))
3163 else if (MacroName.equals(
"bool"))
3178 case Decl::Function:
3186 case Decl::ObjCMethod:
3208 case Decl::ClassTemplatePartialSpecialization:
3216 case Decl::UnresolvedUsingValue:
3217 case Decl::UnresolvedUsingTypename:
3220 case Decl::ObjCPropertyImpl:
3221 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3235 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
3236 switch (TD->getTagKind()) {
3250 bool IncludeUndefined,
3251 bool TargetTypeIsPointer =
false) {
3254 Results.EnterNewScope();
3260 if (IncludeUndefined || MD) {
3262 if (MI->isUsedForHeaderGuard())
3265 Results.AddResult(Result(M->first,
3268 TargetTypeIsPointer)));
3272 Results.ExitScope();
3277 ResultBuilder &Results) {
3280 Results.EnterNewScope();
3282 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3283 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3284 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3286 Results.ExitScope();
3293 unsigned NumResults) {
3351 llvm_unreachable(
"Invalid ParserCompletionContext!");
3363 ResultBuilder &Results) {
3366 while (isa<BlockDecl>(CurContext))
3377 if (!
P->getDeclName())
3383 Results.getCodeCompletionTUInfo());
3391 Overridden->getDeclContext());
3394 llvm::raw_string_ostream OS(Str);
3395 NNS->
print(OS, Policy);
3396 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
3398 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
3401 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
3402 Overridden->getNameAsString()));
3404 bool FirstParam =
true;
3411 Builder.AddPlaceholderChunk(
3412 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
3420 Results.Ignore(Overridden);
3427 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3428 CodeCompleter->getCodeCompletionTUInfo(),
3430 Results.EnterNewScope();
3438 PP.getHeaderSearchInfo().collectAllModules(Modules);
3439 for (
unsigned I = 0, N = Modules.size(); I != N; ++I) {
3440 Builder.AddTypedTextChunk(
3441 Builder.getAllocator().CopyString(Modules[I]->Name));
3442 Results.AddResult(Result(Builder.TakeString(),
3445 Modules[I]->isAvailable()
3449 }
else if (getLangOpts().Modules) {
3451 Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path,
3458 Sub != SubEnd; ++Sub) {
3460 Builder.AddTypedTextChunk(
3461 Builder.getAllocator().CopyString((*Sub)->Name));
3462 Results.AddResult(Result(Builder.TakeString(),
3465 (*Sub)->isAvailable()
3471 Results.ExitScope();
3473 Results.data(),Results.size());
3478 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3479 CodeCompleter->getCodeCompletionTUInfo(),
3481 Results.EnterNewScope();
3486 switch (CompletionContext) {
3489 case PCC_ObjCInterface:
3490 case PCC_ObjCImplementation:
3491 case PCC_ObjCInstanceVariableList:
3493 case PCC_MemberTemplate:
3495 case PCC_LocalDeclarationSpecifiers:
3496 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
3500 case PCC_ParenthesizedExpression:
3501 case PCC_Expression:
3505 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3507 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3513 case PCC_RecoveryInFunction:
3520 if (
CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext))
3521 if (CurMethod->isInstance())
3522 Results.setObjectTypeQualifiers(
3525 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3527 CodeCompleter->includeGlobals());
3530 Results.ExitScope();
3532 switch (CompletionContext) {
3533 case PCC_ParenthesizedExpression:
3534 case PCC_Expression:
3536 case PCC_RecoveryInFunction:
3543 case PCC_ObjCInterface:
3544 case PCC_ObjCImplementation:
3545 case PCC_ObjCInstanceVariableList:
3547 case PCC_MemberTemplate:
3551 case PCC_LocalDeclarationSpecifiers:
3555 if (CodeCompleter->includeMacros())
3559 Results.data(),Results.size());
3565 bool AtArgumentExpression,
3567 ResultBuilder &Results);
3570 bool AllowNonIdentifiers,
3571 bool AllowNestedNameSpecifiers) {
3573 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3574 CodeCompleter->getCodeCompletionTUInfo(),
3575 AllowNestedNameSpecifiers
3578 Results.EnterNewScope();
3581 Results.AddResult(Result(
"const"));
3582 Results.AddResult(Result(
"volatile"));
3583 if (getLangOpts().
C99)
3584 Results.AddResult(Result(
"restrict"));
3590 Results.AddResult(
"final");
3592 if (AllowNonIdentifiers) {
3593 Results.AddResult(Result(
"operator"));
3597 if (AllowNestedNameSpecifiers) {
3598 Results.allowNestedNameSpecifiers();
3599 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
3600 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3602 CodeCompleter->includeGlobals());
3603 Results.setFilter(
nullptr);
3606 Results.ExitScope();
3612 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
3632 Results.getCompletionContext(),
3633 Results.data(), Results.size());
3638 : PreferredType(PreferredType), IntegralConstantExpression(
false),
3639 ObjCCollection(
false) { }
3651 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3652 CodeCompleter->getCodeCompletionTUInfo(),
3655 Results.setFilter(&ResultBuilder::IsObjCCollection);
3657 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
3659 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3661 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3667 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++I)
3670 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3672 CodeCompleter->includeGlobals());
3674 Results.EnterNewScope();
3676 Results.ExitScope();
3678 bool PreferredTypeIsPointer =
false;
3689 if (CodeCompleter->includeMacros())
3694 Results.data(),Results.size());
3699 CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
3700 else if (getLangOpts().ObjC1)
3701 CodeCompleteObjCInstanceMessage(S, E.
get(), None,
false);
3711 if (Interface->hasDefinition())
3712 return Interface->getDefinition();
3718 if (Protocol->hasDefinition())
3719 return Protocol->getDefinition();
3743 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++I) {
3748 std::string PlaceholderStr =
3751 if (I == N - 1 && BlockProtoLoc &&
3753 PlaceholderStr +=
", ...";
3766 bool AllowCategories,
bool AllowNullaryMethods,
DeclContext *CurContext,
3767 AddedPropertiesSet &AddedProperties, ResultBuilder &Results,
3768 bool IsBaseExprStatement =
false,
bool IsClassProperty =
false) {
3776 if (!AddedProperties.insert(
P->getIdentifier()).second)
3781 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
3782 !IsBaseExprStatement) {
3783 Results.MaybeAddResult(Result(
P, Results.getBasePriority(
P),
nullptr),
3795 Results.MaybeAddResult(Result(
P, Results.getBasePriority(
P),
nullptr),
3803 Results.getCodeCompletionTUInfo());
3806 BlockLoc, BlockProtoLoc);
3807 Results.MaybeAddResult(
3808 Result(Builder.TakeString(),
P, Results.getBasePriority(
P)),
3813 if (!
P->isReadOnly()) {
3815 Results.getCodeCompletionTUInfo());
3819 Builder.AddTypedTextChunk(
3820 Results.getAllocator().CopyString(
P->getName()));
3825 BlockProtoLoc,
true);
3827 Builder.AddPlaceholderChunk(
3828 Builder.getAllocator().CopyString(PlaceholderStr));
3835 Results.MaybeAddResult(
3836 Result(Builder.TakeString(),
P,
3837 Results.getBasePriority(
P) +
3845 if (IsClassProperty) {
3854 if (AllowNullaryMethods) {
3859 IdentifierInfo *Name = M->getSelector().getIdentifierInfoForSlot(0);
3862 if (!AddedProperties.insert(Name).second)
3865 Results.getCodeCompletionTUInfo());
3867 Builder.AddTypedTextChunk(
3868 Results.getAllocator().CopyString(Name->
getName()));
3869 Results.MaybeAddResult(
3870 Result(Builder.TakeString(), M,
3875 if (IsClassProperty) {
3876 for (
const auto *M : Container->
methods()) {
3880 if (!M->getSelector().isUnarySelector() ||
3881 M->getReturnType()->isVoidType() || M->isInstanceMethod())
3886 for (
auto *M : Container->
methods()) {
3887 if (M->getSelector().isUnarySelector())
3895 for (
auto *
P : Protocol->protocols())
3897 CurContext, AddedProperties, Results,
3898 IsBaseExprStatement, IsClassProperty);
3900 if (AllowCategories) {
3902 for (
auto *Cat : IFace->known_categories())
3904 CurContext, AddedProperties, Results,
3905 IsBaseExprStatement, IsClassProperty);
3909 for (
auto *I : IFace->all_referenced_protocols())
3911 CurContext, AddedProperties, Results,
3912 IsBaseExprStatement, IsClassProperty);
3915 if (IFace->getSuperClass())
3917 AllowNullaryMethods, CurContext, AddedProperties,
3918 Results, IsBaseExprStatement, IsClassProperty);
3920 = dyn_cast<ObjCCategoryDecl>(Container)) {
3924 CurContext, AddedProperties, Results,
3925 IsBaseExprStatement, IsClassProperty);
3930 ResultBuilder &Results,
Scope *S,
3938 Results.allowNestedNameSpecifiers();
3939 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
3945 if (!Results.empty()) {
3951 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
3953 IsDependent = Ctx->isDependentContext();
3966 bool IsBaseExprStatement) {
3967 if (!Base || !CodeCompleter)
3970 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
3973 Base = ConvertedBase.
get();
4002 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4003 CodeCompleter->getCodeCompletionTUInfo(),
4005 &ResultBuilder::IsMember);
4006 Results.EnterNewScope();
4012 if (
const auto *TD =
4018 if (
auto *RD = ICNT->getDecl())
4022 AddedPropertiesSet AddedProperties;
4027 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
4030 AddedProperties, Results, IsBaseExprStatement);
4036 CurContext, AddedProperties, Results,
4037 IsBaseExprStatement);
4044 Class = ObjCPtr->getInterfaceDecl();
4050 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4051 Results.setFilter(&ResultBuilder::IsObjCIvar);
4053 CodeCompleter->includeGlobals());
4059 Results.ExitScope();
4063 Results.getCompletionContext(),
4064 Results.data(),Results.size());
4070 bool IsBaseExprStatement) {
4077 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4078 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4079 &ResultBuilder::IsMember);
4080 Results.EnterNewScope();
4081 AddedPropertiesSet AddedProperties;
4083 true, CurContext, AddedProperties,
4084 Results, IsBaseExprStatement,
4086 Results.ExitScope();
4088 Results.data(), Results.size());
4095 ResultBuilder::LookupFilter Filter =
nullptr;
4100 Filter = &ResultBuilder::IsEnum;
4105 Filter = &ResultBuilder::IsUnion;
4112 Filter = &ResultBuilder::IsClassOrStruct;
4117 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
4120 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4121 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
4122 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4125 Results.setFilter(Filter);
4127 CodeCompleter->includeGlobals());
4129 if (CodeCompleter->includeGlobals()) {
4131 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
4136 Results.data(),Results.size());
4142 Results.AddResult(
"const");
4144 Results.AddResult(
"volatile");
4146 Results.AddResult(
"restrict");
4148 Results.AddResult(
"_Atomic");
4150 Results.AddResult(
"__unaligned");
4154 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4155 CodeCompleter->getCodeCompletionTUInfo(),
4157 Results.EnterNewScope();
4159 Results.ExitScope();
4161 Results.getCompletionContext(),
4162 Results.data(), Results.size());
4167 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4168 CodeCompleter->getCodeCompletionTUInfo(),
4170 Results.EnterNewScope();
4172 if (LangOpts.CPlusPlus11) {
4173 Results.AddResult(
"noexcept");
4177 Results.AddResult(
"final");
4179 Results.AddResult(
"override");
4182 Results.ExitScope();
4184 Results.data(), Results.size());
4188 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
4192 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
4195 SwitchStmt *Switch = getCurFunction()->SwitchStack.back();
4200 CodeCompleteExpression(S, Data);
4214 llvm::SmallPtrSet<EnumConstantDecl *, 8> EnumeratorsSeen;
4223 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CaseVal))
4225 = dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
4232 EnumeratorsSeen.insert(Enumerator);
4245 Qualifier = DRE->getQualifier();
4249 if (getLangOpts().
CPlusPlus && !Qualifier && EnumeratorsSeen.empty()) {
4257 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4258 CodeCompleter->getCodeCompletionTUInfo(),
4260 Results.EnterNewScope();
4262 if (EnumeratorsSeen.count(E))
4266 Results.AddResult(R, CurContext,
nullptr,
false);
4268 Results.ExitScope();
4273 if (CodeCompleter->includeMacros()) {
4280 Results.data(),Results.size());
4284 if (Args.size() && !Args.data())
4287 for (
unsigned I = 0; I != Args.size(); ++I)
4300 if (!CandidateSet.
empty()) {
4303 CandidateSet.
begin(), CandidateSet.
end(),
4310 for (
auto &Candidate : CandidateSet) {
4311 if (Candidate.Function && Candidate.Function->isDeleted())
4313 if (Candidate.Viable)
4322 ArrayRef<ResultCandidate> Candidates,
4329 for (
auto &Candidate : Candidates) {
4330 if (
auto FType = Candidate.getFunctionType())
4331 if (
auto Proto = dyn_cast<FunctionProtoType>(FType))
4332 if (N < Proto->getNumParams()) {
4334 ParamType = Proto->getParamType(N);
4337 Proto->getParamType(N).getNonReferenceType()))
4348 unsigned CurrentArg,
4349 bool CompleteExpressionWithCurrentArg =
true) {
4351 if (CompleteExpressionWithCurrentArg)
4352 ParamType =
getParamType(SemaRef, Candidates, CurrentArg);
4359 if (!Candidates.empty())
4379 CodeCompleteOrdinaryName(S, PCC_Expression);
4390 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
4391 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
4393 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
4395 if (UME->hasExplicitTemplateArgs()) {
4396 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
4397 TemplateArgs = &TemplateArgsBuffer;
4402 1, UME->isImplicitAccess() ? nullptr : UME->getBase());
4403 ArgExprs.append(Args.begin(), Args.end());
4405 Decls.
append(UME->decls_begin(), UME->decls_end());
4406 const bool FirstArgumentIsBase = !UME->isImplicitAccess() && UME->getBase();
4407 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
4410 FirstArgumentIsBase);
4413 if (
auto MCE = dyn_cast<MemberExpr>(NakedFn))
4415 else if (
auto DRE = dyn_cast<DeclRefExpr>(NakedFn))
4416 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
4418 if (!getLangOpts().CPlusPlus ||
4431 if (isCompleteType(Loc, NakedFn->
getType())) {
4434 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
4435 LookupQualifiedName(R, DC);
4438 ArgExprs.append(Args.begin(), Args.end());
4452 if (!TooManyArguments(FP->getNumParams(), Args.size(),
4455 Results.push_back(ResultCandidate(FP));
4464 !CandidateSet.
empty());
4473 if (!isCompleteType(Loc, Type))
4478 CodeCompleteExpression(S, Type);
4487 for (
auto C : LookupConstructors(RD)) {
4488 if (
auto FD = dyn_cast<FunctionDecl>(C)) {
4493 }
else if (
auto FTD = dyn_cast<FunctionTemplateDecl>(C)) {
4494 AddTemplateOverloadCandidate(FTD,
4509 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
4511 CodeCompleteOrdinaryName(S, PCC_Expression);
4515 CodeCompleteExpression(S, VD->
getType());
4520 if (isa<BlockDecl>(CurContext)) {
4522 ResultType = BSI->ReturnType;
4523 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(CurContext))
4524 ResultType = Function->getReturnType();
4525 else if (
ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(CurContext))
4526 ResultType = Method->getReturnType();
4529 CodeCompleteOrdinaryName(S, PCC_Expression);
4531 CodeCompleteExpression(S, ResultType);
4535 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4536 CodeCompleter->getCodeCompletionTUInfo(),
4538 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4539 Results.EnterNewScope();
4541 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4543 CodeCompleter->includeGlobals());
4549 Results.getCodeCompletionTUInfo());
4550 Builder.AddTypedTextChunk(
"else");
4551 if (Results.includeCodePatterns()) {
4555 Builder.AddPlaceholderChunk(
"statements");
4559 Results.AddResult(Builder.TakeString());
4562 Builder.AddTypedTextChunk(
"else");
4564 Builder.AddTextChunk(
"if");
4568 Builder.AddPlaceholderChunk(
"condition");
4570 Builder.AddPlaceholderChunk(
"expression");
4572 if (Results.includeCodePatterns()) {
4576 Builder.AddPlaceholderChunk(
"statements");
4580 Results.AddResult(Builder.TakeString());
4582 Results.ExitScope();
4587 if (CodeCompleter->includeMacros())
4591 Results.data(),Results.size());
4596 CodeCompleteExpression(S, static_cast<Expr *>(LHS)->getType());
4598 CodeCompleteOrdinaryName(S, PCC_Expression);
4602 bool EnteringContext) {
4603 if (SS.
isEmpty() || !CodeCompleter)
4624 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
4627 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4628 CodeCompleter->getCodeCompletionTUInfo(),
4630 Results.EnterNewScope();
4636 Results.AddResult(
"template");
4643 if (!EnteringContext)
4645 Results.ExitScope();
4647 if (CodeCompleter->includeNamespaceLevelDecls() ||
4649 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4655 auto CC = Results.getCompletionContext();
4656 CC.setCXXScopeSpecifier(SS);
4666 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4667 CodeCompleter->getCodeCompletionTUInfo(),
4669 &ResultBuilder::IsNestedNameSpecifier);
4670 Results.EnterNewScope();
4678 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4680 CodeCompleter->includeGlobals());
4681 Results.ExitScope();
4685 Results.data(),Results.size());
4694 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4695 CodeCompleter->getCodeCompletionTUInfo(),
4697 &ResultBuilder::IsNamespaceOrAlias);
4698 Results.EnterNewScope();
4699 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4701 CodeCompleter->includeGlobals());
4702 Results.ExitScope();
4705 Results.data(),Results.size());
4716 bool SuppressedGlobalResults
4717 = Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
4719 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4720 CodeCompleter->getCodeCompletionTUInfo(),
4721 SuppressedGlobalResults
4724 &ResultBuilder::IsNamespace);
4726 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
4731 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
4735 OrigToLatest[NS->getOriginalNamespace()] = *NS;
4739 Results.EnterNewScope();
4740 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
4741 NS = OrigToLatest.begin(),
4742 NSEnd = OrigToLatest.end();
4745 NS->second, Results.getBasePriority(NS->second),
4747 CurContext,
nullptr,
false);
4748 Results.ExitScope();
4752 Results.getCompletionContext(),
4753 Results.data(),Results.size());
4761 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4762 CodeCompleter->getCodeCompletionTUInfo(),
4764 &ResultBuilder::IsNamespaceOrAlias);
4765 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4767 CodeCompleter->includeGlobals());
4769 Results.getCompletionContext(),
4770 Results.data(),Results.size());
4778 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4779 CodeCompleter->getCodeCompletionTUInfo(),
4781 &ResultBuilder::IsType);
4782 Results.EnterNewScope();
4785 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 4786 if (std::strcmp(Spelling, "?")) \ 4787 Results.AddResult(Result(Spelling)); 4788 #include "clang/Basic/OperatorKinds.def" 4791 Results.allowNestedNameSpecifiers();
4792 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4794 CodeCompleter->includeGlobals());
4798 Results.ExitScope();
4802 Results.data(),Results.size());
4811 AdjustDeclIfTemplate(ConstructorD);
4817 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4818 CodeCompleter->getCodeCompletionTUInfo(),
4820 Results.EnterNewScope();
4823 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
4824 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
4825 for (
unsigned I = 0, E = Initializers.size(); I != E; ++I) {
4826 if (Initializers[I]->isBaseInitializer())
4827 InitializedBases.insert(
4830 InitializedFields.insert(cast<FieldDecl>(
4831 Initializers[I]->getAnyMember()));
4836 Results.getCodeCompletionTUInfo());
4838 bool SawLastInitializer = Initializers.empty();
4840 for (
const auto &
Base : ClassDecl->
bases()) {
4844 = !Initializers.empty() &&
4845 Initializers.back()->isBaseInitializer() &&
4847 QualType(Initializers.back()->getBaseClass(), 0));
4851 Builder.AddTypedTextChunk(
4852 Results.getAllocator().CopyString(
4853 Base.getType().getAsString(Policy)));
4855 Builder.AddPlaceholderChunk(
"args");
4860 SawLastInitializer =
false;
4864 for (
const auto &
Base : ClassDecl->
vbases()) {
4868 = !Initializers.empty() &&
4869 Initializers.back()->isBaseInitializer() &&
4871 QualType(Initializers.back()->getBaseClass(), 0));
4875 Builder.AddTypedTextChunk(
4876 Builder.getAllocator().CopyString(
4877 Base.getType().getAsString(Policy)));
4879 Builder.AddPlaceholderChunk(
"args");
4884 SawLastInitializer =
false;
4888 for (
auto *Field : ClassDecl->
fields()) {
4889 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
4892 = !Initializers.empty() &&
4893 Initializers.back()->isAnyMemberInitializer() &&
4894 Initializers.back()->getAnyMember() == Field;
4898 if (!Field->getDeclName())
4901 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
4902 Field->getIdentifier()->getName()));
4904 Builder.AddPlaceholderChunk(
"args");
4912 SawLastInitializer =
false;
4914 Results.ExitScope();
4917 Results.data(), Results.size());
4930 bool AfterAmpersand) {
4931 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4932 CodeCompleter->getCodeCompletionTUInfo(),
4934 Results.EnterNewScope();
4937 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
4938 bool IncludedThis =
false;
4939 for (
const auto &C : Intro.
Captures) {
4941 IncludedThis =
true;
4950 for (
const auto *D : S->
decls()) {
4951 const auto *Var = dyn_cast<
VarDecl>(D);
4953 !Var->hasLocalStorage() ||
4954 Var->hasAttr<BlocksAttr>())
4957 if (Known.insert(Var->getIdentifier()).second)
4959 CurContext,
nullptr,
false);
4967 Results.ExitScope();
4970 Results.data(), Results.size());
4975 #define OBJC_AT_KEYWORD_NAME(NeedAt,Keyword) ((NeedAt)? "@" Keyword : Keyword) 4978 ResultBuilder &Results,
4985 Results.getCodeCompletionTUInfo());
4986 if (LangOpts.ObjC2) {
4990 Builder.AddPlaceholderChunk(
"property");
4991 Results.AddResult(Result(Builder.TakeString()));
4996 Builder.AddPlaceholderChunk(
"property");
4997 Results.AddResult(Result(Builder.TakeString()));
5002 ResultBuilder &Results,
5009 if (LangOpts.ObjC2) {
5024 Results.getCodeCompletionTUInfo());
5029 Builder.AddPlaceholderChunk(
"name");
5030 Results.AddResult(Result(Builder.TakeString()));
5032 if (Results.includeCodePatterns()) {
5038 Builder.AddPlaceholderChunk(
"class");
5039 Results.AddResult(Result(Builder.TakeString()));
5044 Builder.AddPlaceholderChunk(
"protocol");
5045 Results.AddResult(Result(Builder.TakeString()));
5050 Builder.AddPlaceholderChunk(
"class");
5051 Results.AddResult(Result(Builder.TakeString()));
5057 Builder.AddPlaceholderChunk(
"alias");
5059 Builder.AddPlaceholderChunk(
"class");
5060 Results.AddResult(Result(Builder.TakeString()));
5062 if (Results.getSema().getLangOpts().Modules) {
5066 Builder.AddPlaceholderChunk(
"module");
5067 Results.AddResult(Result(Builder.TakeString()));
5072 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5073 CodeCompleter->getCodeCompletionTUInfo(),
5075 Results.EnterNewScope();
5076 if (isa<ObjCImplDecl>(CurContext))
5082 Results.ExitScope();
5085 Results.data(),Results.size());
5091 Results.getCodeCompletionTUInfo());
5094 const char *EncodeType =
"char[]";
5095 if (Results.getSema().getLangOpts().CPlusPlus ||
5096 Results.getSema().getLangOpts().ConstStrings)
5097 EncodeType =
"const char[]";
5098 Builder.AddResultTypeChunk(EncodeType);
5101 Builder.AddPlaceholderChunk(
"type-name");
5103 Results.AddResult(Result(Builder.TakeString()));
5106 Builder.AddResultTypeChunk(
"Protocol *");
5109 Builder.AddPlaceholderChunk(
"protocol-name");
5111 Results.AddResult(Result(Builder.TakeString()));
5114 Builder.AddResultTypeChunk(
"SEL");
5117 Builder.AddPlaceholderChunk(
"selector");
5119 Results.AddResult(Result(Builder.TakeString()));
5122 Builder.AddResultTypeChunk(
"NSString *");
5124 Builder.AddPlaceholderChunk(
"string");
5125 Builder.AddTextChunk(
"\"");
5126 Results.AddResult(Result(Builder.TakeString()));
5129 Builder.AddResultTypeChunk(
"NSArray *");
5131 Builder.AddPlaceholderChunk(
"objects, ...");
5133 Results.AddResult(Result(Builder.TakeString()));
5136 Builder.AddResultTypeChunk(
"NSDictionary *");
5138 Builder.AddPlaceholderChunk(
"key");
5141 Builder.AddPlaceholderChunk(
"object, ...");
5143 Results.AddResult(Result(Builder.TakeString()));
5146 Builder.AddResultTypeChunk(
"id");
5148 Builder.AddPlaceholderChunk(
"expression");
5150 Results.AddResult(Result(Builder.TakeString()));
5156 Results.getCodeCompletionTUInfo());
5158 if (Results.includeCodePatterns()) {
5163 Builder.AddPlaceholderChunk(
"statements");
5165 Builder.AddTextChunk(
"@catch");
5167 Builder.AddPlaceholderChunk(
"parameter");
5170 Builder.AddPlaceholderChunk(
"statements");
5172 Builder.AddTextChunk(
"@finally");
5174 Builder.AddPlaceholderChunk(
"statements");
5176 Results.AddResult(Result(Builder.TakeString()));
5182 Builder.AddPlaceholderChunk(
"expression");
5183 Results.AddResult(Result(Builder.TakeString()));
5185 if (Results.includeCodePatterns()) {
5190 Builder.AddPlaceholderChunk(
"expression");
5193 Builder.AddPlaceholderChunk(
"statements");
5195 Results.AddResult(Result(Builder.TakeString()));
5200 ResultBuilder &Results,
5211 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5212 CodeCompleter->getCodeCompletionTUInfo(),
5214 Results.EnterNewScope();
5216 Results.ExitScope();
5219 Results.data(),Results.size());
5223 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5224 CodeCompleter->getCodeCompletionTUInfo(),
5226 Results.EnterNewScope();
5229 Results.ExitScope();
5232 Results.data(),Results.size());
5236 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5237 CodeCompleter->getCodeCompletionTUInfo(),
5239 Results.EnterNewScope();
5241 Results.ExitScope();
5244 Results.data(),Results.size());
5251 if (Attributes & NewFlag)
5254 Attributes |= NewFlag;
5268 if (AssignCopyRetMask &&
5286 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5287 CodeCompleter->getCodeCompletionTUInfo(),
5289 Results.EnterNewScope();
5317 Results.getCodeCompletionTUInfo());
5319 Setter.AddTextChunk(
"=");
5320 Setter.AddPlaceholderChunk(
"method");
5325 Results.getCodeCompletionTUInfo());
5327 Getter.AddTextChunk(
"=");
5328 Getter.AddPlaceholderChunk(
"method");
5337 Results.ExitScope();
5340 Results.data(),Results.size());
5353 ArrayRef<IdentifierInfo *> SelIdents,
5354 bool AllowSameLength =
true) {
5355 unsigned NumSelIdents = SelIdents.size();
5365 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
5368 for (
unsigned I = 0; I != NumSelIdents; ++I)
5377 ArrayRef<IdentifierInfo *> SelIdents,
5378 bool AllowSameLength =
true) {
5386 typedef llvm::SmallPtrSet<Selector, 16> VisitedSelectorSet;
5411 ArrayRef<IdentifierInfo *> SelIdents,
5413 VisitedSelectorSet &Selectors,
bool AllowSameLength,
5414 ResultBuilder &Results,
bool InOriginalClass =
true,
5415 bool IsRootClass =
false) {
5419 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
5420 for (
auto *M : Container->
methods()) {
5423 if (M->isInstanceMethod() == WantInstanceMethods ||
5424 (IsRootClass && !WantInstanceMethods)) {
5430 if (!Selectors.insert(M->getSelector()).second)
5433 Result R = Result(M, Results.getBasePriority(M),
nullptr);
5434 R.StartParameter = SelIdents.size();
5435 R.AllParametersAreInformative = (WantKind !=
MK_Any);
5436 if (!InOriginalClass)
5438 Results.MaybeAddResult(R, CurContext);
5444 if (Protocol->hasDefinition()) {
5446 = Protocol->getReferencedProtocols();
5448 E = Protocols.
end();
5450 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5451 Selectors, AllowSameLength, Results,
false, IsRootClass);
5460 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5461 Selectors, AllowSameLength, Results,
false, IsRootClass);
5465 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
5466 CurContext, Selectors, AllowSameLength, Results,
5467 InOriginalClass, IsRootClass);
5471 = CatDecl->getReferencedProtocols();
5473 E = Protocols.
end();
5475 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5476 Selectors, AllowSameLength, Results,
false, IsRootClass);
5480 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5481 Selectors, AllowSameLength, Results, InOriginalClass,
5489 SelIdents, CurContext, Selectors, AllowSameLength, Results,
5494 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5495 Selectors, AllowSameLength, Results, InOriginalClass,
5505 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5506 Class =
Category->getClassInterface();
5513 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5514 CodeCompleter->getCodeCompletionTUInfo(),
5516 Results.EnterNewScope();
5518 VisitedSelectorSet Selectors;
5521 Results.ExitScope();
5524 Results.data(),Results.size());
5530 = dyn_cast_or_null<ObjCInterfaceDecl>(CurContext);
5533 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5534 Class =
Category->getClassInterface();
5541 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5542 CodeCompleter->getCodeCompletionTUInfo(),
5544 Results.EnterNewScope();
5546 VisitedSelectorSet Selectors;
5548 Selectors,
true, Results);
5550 Results.ExitScope();
5553 Results.data(),Results.size());
5558 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5559 CodeCompleter->getCodeCompletionTUInfo(),
5561 Results.EnterNewScope();
5564 bool AddedInOut =
false;
5567 Results.AddResult(
"in");
5568 Results.AddResult(
"inout");
5573 Results.AddResult(
"out");
5575 Results.AddResult(
"inout");
5580 Results.AddResult(
"bycopy");
5581 Results.AddResult(
"byref");
5582 Results.AddResult(
"oneway");
5585 Results.AddResult(
"nonnull");
5586 Results.AddResult(
"nullable");
5587 Results.AddResult(
"null_unspecified");
5595 PP.isMacroDefined(
"IBAction")) {
5597 Results.getCodeCompletionTUInfo(),
5599 Builder.AddTypedTextChunk(
"IBAction");
5601 Builder.AddPlaceholderChunk(
"selector");
5604 Builder.AddTextChunk(
"id");
5606 Builder.AddTextChunk(
"sender");
5617 Results.ExitScope();
5620 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
5621 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5623 CodeCompleter->includeGlobals());
5625 if (CodeCompleter->includeMacros())
5630 Results.data(), Results.size());
5660 IFace = ObjType->getInterface();
5666 IFace = Ptr->getInterfaceDecl();
5680 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5681 .Case(
"retain", IFace)
5682 .Case(
"strong", IFace)
5683 .Case(
"autorelease", IFace)
5684 .Case(
"copy", IFace)
5685 .Case(
"copyWithZone", IFace)
5686 .Case(
"mutableCopy", IFace)
5687 .Case(
"mutableCopyWithZone", IFace)
5688 .Case(
"awakeFromCoder", IFace)
5689 .Case(
"replacementObjectFromCoder", IFace)
5690 .Case(
"class", IFace)
5691 .Case(
"classForCoder", IFace)
5692 .Case(
"superclass", Super)
5695 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5697 .Case(
"alloc", IFace)
5698 .Case(
"allocWithZone", IFace)
5699 .Case(
"class", IFace)
5700 .Case(
"superclass", Super)
5721 Sema &S,
bool NeedSuperKeyword,
5722 ArrayRef<IdentifierInfo *> SelIdents,
5723 ResultBuilder &Results) {
5742 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
5760 CurP != CurPEnd; ++CurP, ++SuperP) {
5763 (*SuperP)->getType()))
5767 if (!(*CurP)->getIdentifier())
5773 Results.getCodeCompletionTUInfo());
5777 Results.getCompletionContext().getBaseType(),
5781 if (NeedSuperKeyword) {
5782 Builder.AddTypedTextChunk(
"super");
5788 if (NeedSuperKeyword)
5789 Builder.AddTextChunk(Builder.getAllocator().CopyString(
5792 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
5796 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I, ++CurP) {
5797 if (I > SelIdents.size())
5800 if (I < SelIdents.size())
5801 Builder.AddInformativeChunk(
5802 Builder.getAllocator().CopyString(
5804 else if (NeedSuperKeyword || I > SelIdents.size()) {
5805 Builder.AddTextChunk(
5806 Builder.getAllocator().CopyString(
5808 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
5809 (*CurP)->getIdentifier()->getName()));
5811 Builder.AddTypedTextChunk(
5812 Builder.getAllocator().CopyString(
5814 Builder.AddPlaceholderChunk(Builder.getAllocator().CopyString(
5815 (*CurP)->getIdentifier()->getName()));
5827 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5828 CodeCompleter->getCodeCompletionTUInfo(),
5830 getLangOpts().CPlusPlus11
5831 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
5832 : &ResultBuilder::IsObjCMessageReceiver);
5834 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5835 Results.EnterNewScope();
5837 CodeCompleter->includeGlobals());
5843 if (Iface->getSuperClass()) {
5844 Results.AddResult(Result(
"super"));
5852 Results.ExitScope();
5854 if (CodeCompleter->includeMacros())
5857 Results.data(), Results.size());
5863 bool AtArgumentExpression) {
5867 CDecl = CurMethod->getClassInterface();
5876 if (CurMethod->isInstanceMethod()) {
5880 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
5881 AtArgumentExpression,
5890 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc,
5891 LookupOrdinaryName);
5892 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
5894 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
5897 CDecl = Iface->getInterface();
5898 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
5905 id.setIdentifier(Super, SuperLoc);
5906 ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc,
id,
5908 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
5910 AtArgumentExpression);
5919 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
5920 AtArgumentExpression,
5927 unsigned NumSelIdents) {
5929 ASTContext &Context = Results.getSema().Context;
5933 Result *ResultsData = Results.data();
5934 for (
unsigned I = 0, N = Results.size(); I != N; ++I) {
5935 Result &R = ResultsData[I];
5936 if (R.Kind == Result::RK_Declaration &&
5937 isa<ObjCMethodDecl>(R.Declaration)) {
5938 if (R.Priority <= BestPriority) {
5939 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
5940 if (NumSelIdents <= Method->param_size()) {
5943 if (R.Priority < BestPriority || PreferredType.
isNull()) {
5944 BestPriority = R.Priority;
5945 PreferredType = MyPreferredType;
5955 return PreferredType;
5960 ArrayRef<IdentifierInfo *> SelIdents,
5961 bool AtArgumentExpression,
5963 ResultBuilder &Results) {
5973 CDecl = Interface->getInterface();
5978 Results.EnterNewScope();
5985 Results.Ignore(SuperMethod);
5991 Results.setPreferredSelector(CurMethod->getSelector());
5993 VisitedSelectorSet Selectors;
5996 SemaRef.
CurContext, Selectors, AtArgumentExpression,
6004 for (uint32_t I = 0,
6015 for (Sema::GlobalMethodPool::iterator M = SemaRef.
MethodPool.begin(),
6020 MethList = MethList->getNext()) {
6024 Result R(MethList->getMethod(),
6025 Results.getBasePriority(MethList->getMethod()),
nullptr);
6026 R.StartParameter = SelIdents.size();
6027 R.AllParametersAreInformative =
false;
6028 Results.MaybeAddResult(R, SemaRef.
CurContext);
6033 Results.ExitScope();
6038 bool AtArgumentExpression,
6041 QualType T = this->GetTypeFromParser(Receiver);
6043 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6044 CodeCompleter->getCodeCompletionTUInfo(),
6049 AtArgumentExpression, IsSuper, Results);
6056 if (AtArgumentExpression) {
6059 if (PreferredType.
isNull())
6060 CodeCompleteOrdinaryName(S, PCC_Expression);
6062 CodeCompleteExpression(S, PreferredType);
6067 Results.getCompletionContext(),
6068 Results.data(), Results.size());
6073 bool AtArgumentExpression,
6077 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
6082 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
6085 RecExpr = Conv.
get();
6098 return CodeCompleteObjCClassMessage(S,
6101 AtArgumentExpression, Super);
6106 }
else if (RecExpr && getLangOpts().CPlusPlus) {
6107 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
6109 RecExpr = Conv.
get();
6110 ReceiverType = RecExpr->
getType();
6115 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6116 CodeCompleter->getCodeCompletionTUInfo(),
6118 ReceiverType, SelIdents));
6120 Results.EnterNewScope();
6127 Results.Ignore(SuperMethod);
6133 Results.setPreferredSelector(CurMethod->getSelector());
6136 VisitedSelectorSet Selectors;
6146 CurContext, Selectors, AtArgumentExpression, Results);
6153 for (
auto *I : QualID->quals())
6155 Selectors, AtArgumentExpression, Results);
6162 CurContext, Selectors, AtArgumentExpression,
6166 for (
auto *I : IFacePtr->quals())
6168 Selectors, AtArgumentExpression, Results);
6177 if (ExternalSource) {
6178 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6180 Selector Sel = ExternalSource->GetExternalSelector(I);
6181 if (Sel.
isNull() || MethodPool.count(Sel))
6184 ReadMethodPool(Sel);
6188 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6189 MEnd = MethodPool.end();
6193 MethList = MethList->getNext()) {
6197 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
6200 Result R(MethList->getMethod(),
6201 Results.getBasePriority(MethList->getMethod()),
nullptr);
6202 R.StartParameter = SelIdents.size();
6203 R.AllParametersAreInformative =
false;
6204 Results.MaybeAddResult(R, CurContext);
6208 Results.ExitScope();
6216 if (AtArgumentExpression) {
6219 if (PreferredType.
isNull())
6220 CodeCompleteOrdinaryName(S, PCC_Expression);
6222 CodeCompleteExpression(S, PreferredType);
6227 Results.getCompletionContext(),
6228 Results.data(),Results.size());
6244 CodeCompleteExpression(S, Data);
6251 if (ExternalSource) {
6252 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6254 Selector Sel = ExternalSource->GetExternalSelector(I);
6255 if (Sel.
isNull() || MethodPool.count(Sel))
6258 ReadMethodPool(Sel);
6262 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6263 CodeCompleter->getCodeCompletionTUInfo(),
6265 Results.EnterNewScope();
6266 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6267 MEnd = MethodPool.end();
6275 Results.getCodeCompletionTUInfo());
6277 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
6279 Results.AddResult(Builder.TakeString());
6283 std::string Accumulator;
6284 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++I) {
6285 if (I == SelIdents.size()) {
6286 if (!Accumulator.empty()) {
6287 Builder.AddInformativeChunk(Builder.getAllocator().CopyString(
6289 Accumulator.clear();
6296 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString( Accumulator));
6297 Results.AddResult(Builder.TakeString());
6299 Results.ExitScope();
6303 Results.data(), Results.size());
6309 bool OnlyForwardDeclarations,
6310 ResultBuilder &Results) {
6313 for (
const auto *D : Ctx->
decls()) {
6315 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
6316 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
6317 Results.AddResult(Result(Proto, Results.getBasePriority(Proto),
nullptr),
6318 CurContext,
nullptr,
false);
6324 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6325 CodeCompleter->getCodeCompletionTUInfo(),
6328 if (CodeCompleter->includeGlobals()) {
6329 Results.EnterNewScope();
6337 Results.Ignore(Protocol);
6343 Results.ExitScope();
6348 Results.data(),Results.size());
6352 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6353 CodeCompleter->getCodeCompletionTUInfo(),
6356 if (CodeCompleter->includeGlobals()) {
6357 Results.EnterNewScope();
6363 Results.ExitScope();
6368 Results.data(),Results.size());
6374 bool OnlyForwardDeclarations,
6375 bool OnlyUnimplemented,
6376 ResultBuilder &Results) {
6379 for (
const auto *D : Ctx->
decls()) {
6381 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
6382 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
6383 (!OnlyUnimplemented || !Class->getImplementation()))
6384 Results.AddResult(Result(Class, Results.getBasePriority(Class),
nullptr),
6385 CurContext,
nullptr,
false);
6390 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6391 CodeCompleter->getCodeCompletionTUInfo(),
6393 Results.EnterNewScope();
6395 if (CodeCompleter->includeGlobals()) {
6401 Results.ExitScope();
6405 Results.data(),Results.size());
6410 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6411 CodeCompleter->getCodeCompletionTUInfo(),
6413 Results.EnterNewScope();
6417 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6418 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
6419 Results.Ignore(CurClass);
6421 if (CodeCompleter->includeGlobals()) {
6427 Results.ExitScope();
6431 Results.data(),Results.size());
6435 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6436 CodeCompleter->getCodeCompletionTUInfo(),
6438 Results.EnterNewScope();
6440 if (CodeCompleter->includeGlobals()) {
6446 Results.ExitScope();
6450 Results.data(),Results.size());
6458 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6459 CodeCompleter->getCodeCompletionTUInfo(),
6464 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6466 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6468 for (
const auto *Cat : Class->visible_categories())
6469 CategoryNames.insert(Cat->getIdentifier());
6473 Results.EnterNewScope();
6475 for (
const auto *D : TU->
decls())
6476 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
6477 if (CategoryNames.insert(
Category->getIdentifier()).second)
6480 CurContext,
nullptr,
false);
6481 Results.ExitScope();
6485 Results.data(),Results.size());
6497 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6500 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
6502 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6503 CodeCompleter->getCodeCompletionTUInfo(),
6509 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6510 Results.EnterNewScope();
6511 bool IgnoreImplemented =
true;
6514 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
6515 CategoryNames.insert(Cat->getIdentifier()).second)
6516 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
6517 CurContext,
nullptr,
false);
6521 IgnoreImplemented =
false;
6523 Results.ExitScope();
6527 Results.data(),Results.size());
6532 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6533 CodeCompleter->getCodeCompletionTUInfo(),
6538 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6540 (!isa<ObjCImplementationDecl>(Container) &&
6541 !isa<ObjCCategoryImplDecl>(Container)))
6546 for (
const auto *D : Container->decls())
6547 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
6548 Results.Ignore(PropertyImpl->getPropertyDecl());
6551 AddedPropertiesSet AddedProperties;
6552 Results.EnterNewScope();
6554 = dyn_cast<ObjCImplementationDecl>(Container))
6557 AddedProperties, Results);
6560 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
6561 false,
false, CurContext,
6562 AddedProperties, Results);
6563 Results.ExitScope();
6567 Results.data(),Results.size());
6573 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6574 CodeCompleter->getCodeCompletionTUInfo(),
6579 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6581 (!isa<ObjCImplementationDecl>(Container) &&
6582 !isa<ObjCCategoryImplDecl>(Container)))
6588 = dyn_cast<ObjCImplementationDecl>(Container))
6589 Class = ClassImpl->getClassInterface();
6591 Class = cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl()
6592 ->getClassInterface();
6600 =
Property->getType().getNonReferenceType().getUnqualifiedType();
6603 Results.setPreferredType(PropertyType);
6608 Results.EnterNewScope();
6609 bool SawSimilarlyNamedIvar =
false;
6610 std::string NameWithPrefix;
6611 NameWithPrefix +=
'_';
6612 NameWithPrefix += PropertyName->
getName();
6613 std::string NameWithSuffix = PropertyName->
getName().str();
6614 NameWithSuffix +=
'_';
6618 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
6619 CurContext,
nullptr,
false);
6623 if ((PropertyName == Ivar->getIdentifier() ||
6624 NameWithPrefix == Ivar->
getName() ||
6625 NameWithSuffix == Ivar->getName())) {
6626 SawSimilarlyNamedIvar =
true;
6630 if (Results.size() &&
6631 Results.data()[Results.size() - 1].Kind
6633 Results.data()[Results.size() - 1].Declaration == Ivar)
6634 Results.data()[Results.size() - 1].Priority--;
6639 if (!SawSimilarlyNamedIvar) {
6650 Policy, Allocator));
6651 Builder.AddTypedTextChunk(Allocator.
CopyString(NameWithPrefix));
6652 Results.AddResult(Result(Builder.TakeString(), Priority,
6656 Results.ExitScope();
6660 Results.data(),Results.size());
6665 typedef llvm::DenseMap<
6674 Optional<bool> WantInstanceMethods,
6676 KnownMethodsMap &KnownMethods,
6677 bool InOriginalClass =
true) {
6680 if (!IFace->hasDefinition())
6683 IFace = IFace->getDefinition();
6687 = IFace->getReferencedProtocols();
6689 E = Protocols.
end();
6692 KnownMethods, InOriginalClass);
6695 for (
auto *Cat : IFace->visible_categories()) {
6697 KnownMethods,
false);
6701 if (IFace->getSuperClass())
6703 WantInstanceMethods, ReturnType,
6704 KnownMethods,
false);
6710 =
Category->getReferencedProtocols();
6712 E = Protocols.
end();
6715 KnownMethods, InOriginalClass);
6718 if (InOriginalClass &&
Category->getClassInterface())
6720 WantInstanceMethods, ReturnType, KnownMethods,
6726 if (!Protocol->hasDefinition())
6728 Protocol = Protocol->getDefinition();
6729 Container = Protocol;
6733 = Protocol->getReferencedProtocols();
6735 E = Protocols.
end();
6738 KnownMethods,
false);
6744 for (
auto *M : Container->
methods()) {
6745 if (!WantInstanceMethods || M->isInstanceMethod() == *WantInstanceMethods) {
6746 if (!ReturnType.
isNull() &&
6750 KnownMethods[M->getSelector()] =
6751 KnownMethodsMap::mapped_type(M, InOriginalClass);
6759 unsigned ObjCDeclQuals,
6788 bool IsInstanceMethod,
6791 VisitedSelectorSet &KnownSelectors,
6792 ResultBuilder &Results) {
6794 if (!PropName || PropName->
getLength() == 0)
6812 const char *CopiedKey;
6815 : Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
6817 operator const char *() {
6821 return CopiedKey = Allocator.
CopyString(Key);
6823 } Key(Allocator, PropName->
getName());
6826 std::string UpperKey = PropName->
getName();
6827 if (!UpperKey.empty())
6830 bool ReturnTypeMatchesProperty = ReturnType.
isNull() ||
6833 bool ReturnTypeMatchesVoid
6837 if (IsInstanceMethod &&
6838 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
6842 Context, Policy, Builder);
6844 Builder.AddTypedTextChunk(Key);
6851 if (IsInstanceMethod &&
6852 ((!ReturnType.
isNull() &&
6857 std::string SelectorName = (Twine(
"is") + UpperKey).str();
6859 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6861 if (ReturnType.
isNull()) {
6863 Builder.AddTextChunk(
"BOOL");
6867 Builder.AddTypedTextChunk(
6875 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
6877 std::string SelectorName = (Twine(
"set") + UpperKey).str();
6879 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6880 if (ReturnType.
isNull()) {
6882 Builder.AddTextChunk(
"void");
6886 Builder.AddTypedTextChunk(
6888 Builder.AddTypedTextChunk(
":");
6890 Context, Policy, Builder);
6891 Builder.AddTextChunk(Key);
6927 if (IsInstanceMethod &&
6929 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
6931 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6933 if (ReturnType.
isNull()) {
6935 Builder.AddTextChunk(
"NSUInteger");
6939 Builder.AddTypedTextChunk(
6941 Results.AddResult(Result(Builder.TakeString(),
6943 UnorderedGetterPriority),
6950 if (IsInstanceMethod &&
6952 std::string SelectorName
6953 = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
6955 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6956 if (ReturnType.
isNull()) {
6958 Builder.AddTextChunk(
"id");
6962 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
6964 Builder.AddTextChunk(
"NSUInteger");
6966 Builder.AddTextChunk(
"index");
6967 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
6973 if (IsInstanceMethod &&
6978 ->getName() ==
"NSArray"))) {
6979 std::string SelectorName
6980 = (Twine(Property->
getName()) +
"AtIndexes").str();
6982 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6983 if (ReturnType.
isNull()) {
6985 Builder.AddTextChunk(
"NSArray *");
6989 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
6991 Builder.AddTextChunk(
"NSIndexSet *");
6993 Builder.AddTextChunk(
"indexes");
6994 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7000 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7001 std::string SelectorName = (Twine(
"get") + UpperKey).str();
7007 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7008 if (ReturnType.
isNull()) {
7010 Builder.AddTextChunk(
"void");
7014 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7016 Builder.AddPlaceholderChunk(
"object-type");
7017 Builder.AddTextChunk(
" **");
7019 Builder.AddTextChunk(
"buffer");
7021 Builder.AddTypedTextChunk(
"range:");
7023 Builder.AddTextChunk(
"NSRange");
7025 Builder.AddTextChunk(
"inRange");
7026 Results.AddResult(Result(Builder.TakeString(), IndexedGetterPriority,
7034 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7035 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
7041 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7042 if (ReturnType.
isNull()) {
7044 Builder.AddTextChunk(
"void");
7048 Builder.AddTypedTextChunk(
"insertObject:");
7050 Builder.AddPlaceholderChunk(
"object-type");
7051 Builder.AddTextChunk(
" *");
7053 Builder.AddTextChunk(
"object");
7055 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7057 Builder.AddPlaceholderChunk(
"NSUInteger");
7059 Builder.AddTextChunk(
"index");
7060 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7066 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7067 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
7073 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7074 if (ReturnType.
isNull()) {
7076 Builder.AddTextChunk(
"void");
7080 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7082 Builder.AddTextChunk(
"NSArray *");
7084 Builder.AddTextChunk(
"array");
7086 Builder.AddTypedTextChunk(
"atIndexes:");
7088 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7090 Builder.AddTextChunk(
"indexes");
7091 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7097 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7098 std::string SelectorName
7099 = (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
7101 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7102 if (ReturnType.
isNull()) {
7104 Builder.AddTextChunk(
"void");
7108 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7110 Builder.AddTextChunk(
"NSUInteger");
7112 Builder.AddTextChunk(
"index");
7113 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7119 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7120 std::string SelectorName
7121 = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
7123 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7124 if (ReturnType.
isNull()) {
7126 Builder.AddTextChunk(
"void");
7130 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7132 Builder.AddTextChunk(
"NSIndexSet *");
7134 Builder.AddTextChunk(
"indexes");
7135 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7141 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7142 std::string SelectorName
7143 = (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
7149 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7150 if (ReturnType.
isNull()) {
7152 Builder.AddTextChunk(
"void");
7156 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7158 Builder.AddPlaceholderChunk(
"NSUInteger");
7160 Builder.AddTextChunk(
"index");
7162 Builder.AddTypedTextChunk(
"withObject:");
7164 Builder.AddTextChunk(
"id");
7166 Builder.AddTextChunk(
"object");
7167 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7173 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7174 std::string SelectorName1
7175 = (Twine(
"replace") + UpperKey +
"AtIndexes").str();
7176 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
7182 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7183 if (ReturnType.
isNull()) {
7185 Builder.AddTextChunk(
"void");
7189 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName1 +
":"));
7191 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7193 Builder.AddTextChunk(
"indexes");
7195 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName2 +
":"));
7197 Builder.AddTextChunk(
"NSArray *");
7199 Builder.AddTextChunk(
"array");
7200 Results.AddResult(Result(Builder.TakeString(), IndexedSetterPriority,
7207 if (IsInstanceMethod &&
7212 ->getName() ==
"NSEnumerator"))) {
7213 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
7215 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7217 if (ReturnType.
isNull()) {
7219 Builder.AddTextChunk(
"NSEnumerator *");
7223 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7224 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7230 if (IsInstanceMethod &&
7232 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
7234 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7235 if (ReturnType.
isNull()) {
7237 Builder.AddPlaceholderChunk(
"object-type");
7238 Builder.AddTextChunk(
" *");
7242 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7244 if (ReturnType.
isNull()) {
7245 Builder.AddPlaceholderChunk(
"object-type");
7246 Builder.AddTextChunk(
" *");
7250 Builder.getAllocator()));
7253 Builder.AddTextChunk(
"object");
7254 Results.AddResult(Result(Builder.TakeString(), UnorderedGetterPriority,
7261 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7262 std::string SelectorName
7263 = (Twine(
"add") + UpperKey + Twine(
"Object")).str();
7265 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7266 if (ReturnType.
isNull()) {
7268 Builder.AddTextChunk(
"void");
7272 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7274 Builder.AddPlaceholderChunk(
"object-type");
7275 Builder.AddTextChunk(
" *");
7277 Builder.AddTextChunk(
"object");
7278 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7284 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7285 std::string SelectorName = (Twine(
"add") + UpperKey).str();
7287 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7288 if (ReturnType.
isNull()) {
7290 Builder.AddTextChunk(
"void");
7294 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7296 Builder.AddTextChunk(
"NSSet *");
7298 Builder.AddTextChunk(
"objects");
7299 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7305 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7306 std::string SelectorName
7307 = (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
7309 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7310 if (ReturnType.
isNull()) {
7312 Builder.AddTextChunk(
"void");
7316 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7318 Builder.AddPlaceholderChunk(
"object-type");
7319 Builder.AddTextChunk(
" *");
7321 Builder.AddTextChunk(
"object");
7322 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7328 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7329 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
7331 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7332 if (ReturnType.
isNull()) {
7334 Builder.AddTextChunk(
"void");
7338 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7340 Builder.AddTextChunk(
"NSSet *");
7342 Builder.AddTextChunk(
"objects");
7343 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7349 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7350 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
7352 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7353 if (ReturnType.
isNull()) {
7355 Builder.AddTextChunk(
"void");
7359 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName +
":"));
7361 Builder.AddTextChunk(
"NSSet *");
7363 Builder.AddTextChunk(
"objects");
7364 Results.AddResult(Result(Builder.TakeString(), UnorderedSetterPriority,
7371 if (!IsInstanceMethod &&
7376 ->getName() ==
"NSSet"))) {
7377 std::string SelectorName
7378 = (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
7380 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7382 if (ReturnType.
isNull()) {
7384 Builder.AddTextChunk(
"NSSet<NSString *> *");
7388 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7395 if (!IsInstanceMethod &&
7399 std::string SelectorName
7400 = (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
7402 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7404 if (ReturnType.
isNull()) {
7406 Builder.AddTextChunk(
"BOOL");
7410 Builder.AddTypedTextChunk(Allocator.
CopyString(SelectorName));
7421 QualType ReturnType = GetTypeFromParser(ReturnTy);
7422 Decl *IDecl =
nullptr;
7425 IDecl = cast<Decl>(OCD);
7429 bool IsInImplementation =
false;
7430 if (
Decl *D = IDecl) {
7432 SearchDecl = Impl->getClassInterface();
7433 IsInImplementation =
true;
7435 = dyn_cast<ObjCCategoryImplDecl>(D)) {
7436 SearchDecl = CatImpl->getCategoryDecl();
7437 IsInImplementation =
true;
7442 if (!SearchDecl && S) {
7444 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
7455 KnownMethodsMap KnownMethods;
7457 ReturnType, KnownMethods);
7461 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7462 CodeCompleter->getCodeCompletionTUInfo(),
7464 Results.EnterNewScope();
7466 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7467 MEnd = KnownMethods.end();
7471 Results.getCodeCompletionTUInfo());
7474 if (!IsInstanceMethod) {
7481 if (ReturnType.
isNull()) {
7492 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
7493 Sel.getNameForSlot(0)));
7499 P != PEnd; (void)++
P, ++I) {
7502 Builder.AddTypedTextChunk(
":");
7503 else if (I < Sel.getNumArgs()) {
7505 Builder.AddTypedTextChunk(
7506 Builder.getAllocator().CopyString(Sel.getNameForSlot(I) +
":"));
7513 ParamType = (*P)->getType();
7515 ParamType = (*P)->getOriginalType();
7520 (*P)->getObjCDeclQualifier(),
7525 Builder.AddTextChunk(Builder.getAllocator().CopyString(
Id->getName()));
7531 Builder.AddTextChunk(
"...");
7534 if (IsInImplementation && Results.includeCodePatterns()) {
7541 Builder.AddTextChunk(
"return");
7543 Builder.AddPlaceholderChunk(
"expression");
7546 Builder.AddPlaceholderChunk(
"statements");
7553 if (!M->second.getInt())
7556 Results.AddResult(Result(Builder.TakeString(), Method, Priority));
7563 Containers.push_back(SearchDecl);
7565 VisitedSelectorSet KnownSelectors;
7566 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7567 MEnd = KnownMethods.end();
7569 KnownSelectors.insert(M->first);
7575 IFace =
Category->getClassInterface();
7579 Containers.push_back(Cat);
7581 if (IsInstanceMethod) {
7582 for (
unsigned I = 0, N = Containers.size(); I != N; ++I)
7583 for (
auto *
P : Containers[I]->instance_properties())
7585 KnownSelectors, Results);
7589 Results.ExitScope();
7593 Results.data(),Results.size());
7597 bool IsInstanceMethod,
7598 bool AtParameterName,
7603 if (ExternalSource) {
7604 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
7606 Selector Sel = ExternalSource->GetExternalSelector(I);
7607 if (Sel.
isNull() || MethodPool.count(Sel))
7610 ReadMethodPool(Sel);
7616 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7617 CodeCompleter->getCodeCompletionTUInfo(),
7621 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
7623 Results.EnterNewScope();
7624 for (GlobalMethodPool::iterator M = MethodPool.begin(),
7625 MEnd = MethodPool.end();
7627 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first :
7630 MethList = MethList->getNext()) {
7634 if (AtParameterName) {
7636 unsigned NumSelIdents = SelIdents.size();
7638 NumSelIdents <= MethList->getMethod()->param_size()) {
7640 MethList->getMethod()->parameters()[NumSelIdents - 1];
7643 Results.getCodeCompletionTUInfo());
7644 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
7646 Results.AddResult(Builder.TakeString());
7653 Result R(MethList->getMethod(),
7654 Results.getBasePriority(MethList->getMethod()),
nullptr);
7655 R.StartParameter = SelIdents.size();
7656 R.AllParametersAreInformative =
false;
7657 R.DeclaringEntity =
true;
7658 Results.MaybeAddResult(R, CurContext);
7662 Results.ExitScope();
7664 if (!AtParameterName && !SelIdents.empty() &&
7665 SelIdents.front()->getName().startswith(
"init")) {
7666 for (
const auto &M : PP.macros()) {
7667 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
7669 Results.EnterNewScope();
7671 Results.getCodeCompletionTUInfo());
7672 Builder.AddTypedTextChunk(
7673 Builder.getAllocator().CopyString(M.first->getName()));
7676 Results.ExitScope();
7682 Results.data(),Results.size());
7686 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7687 CodeCompleter->getCodeCompletionTUInfo(),
7689 Results.EnterNewScope();
7693 Results.getCodeCompletionTUInfo());
7694 Builder.AddTypedTextChunk(
"if");
7696 Builder.AddPlaceholderChunk(
"condition");
7697 Results.AddResult(Builder.TakeString());
7700 Builder.AddTypedTextChunk(
"ifdef");
7702 Builder.AddPlaceholderChunk(
"macro");
7703 Results.AddResult(Builder.TakeString());
7706 Builder.AddTypedTextChunk(
"ifndef");
7708 Builder.AddPlaceholderChunk(
"macro");
7709 Results.AddResult(Builder.TakeString());
7711 if (InConditional) {
7713 Builder.AddTypedTextChunk(
"elif");
7715 Builder.AddPlaceholderChunk(
"condition");
7716 Results.AddResult(Builder.TakeString());
7719 Builder.AddTypedTextChunk(
"else");
7720 Results.AddResult(Builder.TakeString());
7723 Builder.AddTypedTextChunk(
"endif");
7724 Results.AddResult(Builder.TakeString());
7728 Builder.AddTypedTextChunk(
"include");
7730 Builder.AddTextChunk(
"\"");
7731 Builder.AddPlaceholderChunk(
"header");
7732 Builder.AddTextChunk(
"\"");
7733 Results.AddResult(Builder.TakeString());
7736 Builder.AddTypedTextChunk(
"include");
7738 Builder.AddTextChunk(
"<");
7739 Builder.AddPlaceholderChunk(
"header");
7740 Builder.AddTextChunk(
">");
7741 Results.AddResult(Builder.TakeString());
7744 Builder.AddTypedTextChunk(
"define");
7746 Builder.AddPlaceholderChunk(
"macro");
7747 Results.AddResult(Builder.TakeString());
7750 Builder.AddTypedTextChunk(
"define");
7752 Builder.AddPlaceholderChunk(
"macro");
7754 Builder.AddPlaceholderChunk(
"args");
7756 Results.AddResult(Builder.TakeString());
7759 Builder.AddTypedTextChunk(
"undef");
7761 Builder.AddPlaceholderChunk(
"macro");
7762 Results.AddResult(Builder.TakeString());
7765 Builder.AddTypedTextChunk(
"line");
7767 Builder.AddPlaceholderChunk(
"number");
7768 Results.AddResult(Builder.TakeString());
7771 Builder.AddTypedTextChunk(
"line");
7773 Builder.AddPlaceholderChunk(
"number");
7775 Builder.AddTextChunk(
"\"");
7776 Builder.AddPlaceholderChunk(
"filename");
7777 Builder.AddTextChunk(
"\"");
7778 Results.AddResult(Builder.TakeString());
7781 Builder.AddTypedTextChunk(
"error");
7783 Builder.AddPlaceholderChunk(
"message");
7784 Results.AddResult(Builder.TakeString());
7787 Builder.AddTypedTextChunk(
"pragma");
7789 Builder.AddPlaceholderChunk(
"arguments");
7790 Results.AddResult(Builder.TakeString());
7792 if (getLangOpts().ObjC1) {
7794 Builder.AddTypedTextChunk(
"import");
7796 Builder.AddTextChunk(
"\"");
7797 Builder.AddPlaceholderChunk(
"header");
7798 Builder.AddTextChunk(
"\"");
7799 Results.AddResult(Builder.TakeString());
7802 Builder.AddTypedTextChunk(
"import");
7804 Builder.AddTextChunk(
"<");
7805 Builder.AddPlaceholderChunk(
"header");
7806 Builder.AddTextChunk(
">");
7807 Results.AddResult(Builder.TakeString());
7811 Builder.AddTypedTextChunk(
"include_next");
7813 Builder.AddTextChunk(
"\"");
7814 Builder.AddPlaceholderChunk(
"header");
7815 Builder.AddTextChunk(
"\"");
7816 Results.AddResult(Builder.TakeString());
7819 Builder.AddTypedTextChunk(
"include_next");
7821 Builder.AddTextChunk(
"<");
7822 Builder.AddPlaceholderChunk(
"header");
7823 Builder.AddTextChunk(
">");
7824 Results.AddResult(Builder.TakeString());
7827 Builder.AddTypedTextChunk(
"warning");
7829 Builder.AddPlaceholderChunk(
"message");
7830 Results.AddResult(Builder.TakeString());
7837 Results.ExitScope();
7841 Results.data(), Results.size());
7845 CodeCompleteOrdinaryName(S,
7851 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7852 CodeCompleter->getCodeCompletionTUInfo(),
7855 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
7858 Results.getCodeCompletionTUInfo());
7859 Results.EnterNewScope();
7861 MEnd = PP.macro_end();
7863 Builder.AddTypedTextChunk(Builder.getAllocator().CopyString(
7864 M->first->getName()));
7869 Results.ExitScope();
7870 }
else if (IsDefinition) {
7875 Results.data(), Results.size());
7879 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7880 CodeCompleter->getCodeCompletionTUInfo(),
7883 if (!CodeCompleter || CodeCompleter->includeMacros())
7887 Results.EnterNewScope();
7889 Results.getCodeCompletionTUInfo());
7890 Builder.AddTypedTextChunk(
"defined");
7893 Builder.AddPlaceholderChunk(
"macro");
7895 Results.AddResult(Builder.TakeString());
7896 Results.ExitScope();
7900 Results.data(), Results.size());
7906 unsigned Argument) {
7921 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7922 CodeCompleter->getCodeCompletionTUInfo(),
7924 Results.EnterNewScope();
7925 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
7926 for (
const char *Platform : llvm::makeArrayRef(Platforms)) {
7929 Twine(Platform) +
"ApplicationExtension")));
7931 Results.ExitScope();
7940 ResultBuilder Builder(*
this, Allocator, CCTUInfo,
7942 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
7943 CodeCompletionDeclConsumer Consumer(Builder,
7949 if (!CodeCompleter || CodeCompleter->includeMacros())
7953 Results.insert(Results.end(),
7954 Builder.data(), Builder.data() + Builder.size());
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
The receiver is the instance of the superclass object.
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 AddPrettyFunctionResults(const LangOptions &LangOpts, ResultBuilder &Results)
bool hasDefinition() const
Determine whether this class has been defined.
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
static void MaybeAddSentinel(Preprocessor &PP, const NamedDecl *FunctionOrMethod, CodeCompletionBuilder &Result)
Priority for a declaration that is in the local scope.
An instance of this class is created to represent a function declaration or definition.
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
An Objective-C method being used as a property.
The receiver is an object instance.
ExternalSemaSource * getExternalSource() const
A C++ namespace alias declaration.
protocol_range protocols() const
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
const TypeClass * getTypePtr() const
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Any kind of method, provided it means other specified criteria.
bool isBlockPointerType() const
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
This is a scope that corresponds to the parameters within a function prototype.
param_iterator param_begin() const
bool isMemberPointerType() const
std::vector< Module * >::iterator submodule_iterator
unsigned param_size() const
A static_assert or _Static_assert node.
Selector getSelector() const
ObjCInterfaceDecl * getClassInterface()
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...
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...
ObjCDeclQualifier getObjCDeclQualifier() const
const TypeClass * getTypePtr() const
Code completion occurs within a class, struct, or union.
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, bool IsSuper=false)
Code completion for a selector, as in an @selector expression.
CodeCompleteConsumer::OverloadCandidate ResultCandidate
submodule_iterator submodule_begin()
void AddTextChunk(const char *Text)
Add a new text chunk.
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
static void AddRecordMembersCompletionResults(Sema &SemaRef, ResultBuilder &Results, Scope *S, QualType BaseType, RecordDecl *RD)
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...
Code completion where an Objective-C class message is expected.
FunctionType - C99 6.7.5.3 - Function Declarators.
static bool isObjCReceiverType(ASTContext &C, QualType T)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS)
static CharSourceRange getTokenRange(SourceRange R)
Code completion within a type-qualifier list.
bool isRecordType() const
static bool isReservedName(const IdentifierInfo *Id, bool doubleUnderscoreOnly=false)
Determine whether Id is a name reserved for the implementation (C99 7.1.3, C++ [lib.global.names]).
bool isEmpty() const
No scope specifier.
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.
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...
Decl - This represents one declaration (or definition), e.g.
void AddChunk(CodeCompletionString::ChunkKind CK, const char *Text="")
Add a new chunk.
Captures information about "declaration specifiers" specific to Objective-C.
void CodeCompleteUsing(Scope *S)
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for...
static void AddFunctionSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
virtual uint32_t GetNumExternalSelectors()
Returns the number of selectors known to the external AST source.
bool isOverrideSpecified() const
known_categories_range known_categories() const
std::ptrdiff_t difference_type
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression)
Defines the clang::MacroInfo and clang::MacroDirective classes.
Adjustment for KVC code pattern priorities when it doesn't look like the.
void CodeCompleteNaturalLanguage()
pointer(const DeclIndexPair &Value)
The base class of the type hierarchy.
An unspecified code-completion context.
bool isObjCContainer() const
NamespaceDecl - Represent a C++ namespace.
Wrapper for source info for typedefs.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
A C++ non-type template parameter.
An Objective-C @interface for a category.
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext)
A container of type source information.
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...
ObjCMethodDecl * getMethod() const
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
An Objective-C block property completed as a setter with a block placeholder.
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
static bool isAcceptableObjCSelector(Selector Sel, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, bool AllowSameLength=true)
param_const_iterator param_end() const
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
Code completion occurred where an Objective-C message receiver is expected.
iterator(const NamedDecl *SingleDecl, unsigned Index)
void CodeCompleteObjCMessageReceiver(Scope *S)
void CodeCompleteObjCPropertyGetter(Scope *S)
Code completion occurred on the right-hand side of a member access expression using the arrow operato...
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Code completion occurred after the "enum" keyword, to indicate an enumeration name.
enumerator_range enumerators() const
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...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
SmallVector< SwitchStmt *, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
A left bracket ('[').
Information about one declarator, including the parsed type information and the identifier.
unsigned getNumParams() const
bool isEnumeralType() const
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
const T * getAs() const
Member-template getAs<specific type>'.
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
virtual Selector GetExternalSelector(uint32_t ID)
Resolve a selector ID into a selector.
TypeSpecifierType
Specifies the kind of type.
The "__interface" keyword.
An Objective-C @synthesize definition.
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static const TST TST_interface
void AddOptionalChunk(CodeCompletionString *Optional)
Add a new optional chunk.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
Code completion occurred within the instance variable list of an Objective-C interface, implementation, or category implementation.
Stores a list of template parameters for a TemplateDecl and its derived classes.
void AddTypedTextChunk(const char *Text)
Add a new typed-text chunk.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
Describes how types, statements, expressions, and declarations should be printed. ...
Code completion occurs within an Objective-C implementation or category implementation.
The entity is not available; any use of it will be an error.
ParmVarDecl - Represents a parameter to a function.
Defines the clang::Expr interface and subclasses for C++ expressions.
The collection of all-type qualifiers we support.
tok::TokenKind ContextKind
bool isObjCObjectOrInterfaceType() const
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
RecordDecl - Represents a struct/union/class.
static void AddTypedefResult(ResultBuilder &Results)
static void AddObjCProperties(const CodeCompletionContext &CCContext, ObjCContainerDecl *Container, bool AllowCategories, bool AllowNullaryMethods, DeclContext *CurContext, AddedPropertiesSet &AddedProperties, ResultBuilder &Results, bool IsBaseExprStatement=false, bool IsClassProperty=false)
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
instprop_range instance_properties() const
static void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
One of these records is kept for each identifier that is lexed.
CodeCompletionString * TakeString()
Take the resulting completion string.
This table allows us to fully hide how we implement multi-keyword caching.
void CodeCompleteObjCInterfaceDecl(Scope *S)
SmallVector< Decl *, 4 > IgnoreDecls
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
const ParmVarDecl *const * param_const_iterator
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr *> Args)
A "string" used to describe how code completion can be performed for an entity.
field_range fields() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
static const TST TST_class
bool isObjCIdType() const
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true)
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
An Objective-C @protocol declaration.
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
static void AddTypeSpecifierResults(const LangOptions &LangOpts, ResultBuilder &Results)
Add type specifiers for the current language as keyword results.
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
Code completion occurs following one or more template headers within a class.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
method_range methods() const
ObjCMethodDecl * getSetterMethodDecl() const
A C++ template template parameter.
void CodeCompleteCase(Scope *S)
ParmVarDecl * getParam(unsigned i) const
An Objective-C instance method.
static const TST TST_enum
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
TSC getTypeSpecComplex() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
visible_categories_range visible_categories() const
llvm::DenseMap< Selector, llvm::PointerIntPair< ObjCMethodDecl *, 1, bool > > KnownMethodsMap
const LangOptions & getLangOpts() const
bool isObjCQualifiedClassType() const
void * getAsOpaquePtr() const
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
Describes a module or submodule.
Code completion occurs where only a type is permitted.
unsigned getTypeQuals() const
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
unsigned SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
Code completion occurs at top-level or namespace context.
ArrayRef< ParmVarDecl * > parameters() const
Values of this type can be null.
bool isUnarySelector() const
An Objective-C @property declaration.
static bool shouldIgnoreDueToReservedName(const NamedDecl *ND, Sema &SemaRef)
static ObjCContainerDecl * getContainerDef(ObjCContainerDecl *Container)
Retrieve the container definition, if any?
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
An allocator used specifically for the purpose of code completion.
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
Represents a C++ unqualified-id that has been parsed.
param_iterator param_end() const
Priority for a nested-name-specifier.
Represents the results of name lookup.
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 DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
Namespaces, declared with 'namespace foo {}'.
A convenient class for passing around template argument information.
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
Code completion occurs following one or more template headers.
void CodeCompleteBracketDeclarator(Scope *S)
static void AddStaticAssertResult(CodeCompletionBuilder &Builder, ResultBuilder &Results, const LangOptions &LangOpts)
Wrapper for source info for functions.
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
static std::string formatObjCParamQualifiers(unsigned ObjCQuals, QualType &Type)
Code completion occurs within an expression.
Whether values of this type can be null is (explicitly) unspecified.
Code completion occurred where a preprocessor directive is expected.
A friend of a previously-undeclared entity.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
TypeDecl - Represents a declaration of a type.
void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
bool SuppressScope
Suppresses printing of scope specifiers.
Code completion occurred within an Objective-C implementation or category implementation.
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...
void MarkDeducedTemplateParameters(const FunctionTemplateDecl *FunctionTemplate, llvm::SmallBitVector &Deduced)
static void AddObjCMethods(ObjCContainerDecl *Container, bool WantInstanceMethods, ObjCMethodKind WantKind, ArrayRef< 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 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.
TSS getTypeSpecSign() const
Priority for the Objective-C "_cmd" implicit parameter.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Values of this type can never be null.
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
Scope - A scope is a transient data structure that is used while parsing the program.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
reference operator*() const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
submodule_iterator submodule_end()
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...
void append(iterator I, iterator E)
Code completion occurred where a namespace or namespace alias is expected.
Represents a C++ nested-name-specifier or a global scope specifier.
Represents an Objective-C protocol declaration.
static void AddMacroResults(Preprocessor &PP, ResultBuilder &Results, bool IncludeUndefined, bool TargetTypeIsPointer=false)
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
const LangOptions & getLangOpts() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
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.
A right brace ('}').
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
Represents an ObjC class declaration.
QualType getReturnType() const
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo *> SelIdents, bool AllowSameLength=true)
Member name lookup, which finds the names of class/struct/union members.
A comma separator (',').
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
macro_iterator macro_end(bool IncludeExternalMacros=true) const
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
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...
unsigned getLength() const
Efficiently return the length of this identifier info.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
const DeclIndexPair * operator->() const
CXCursorKind
Describes the kind of entity that a cursor refers to.
void CodeCompleteAvailabilityPlatformName()
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Code completion occurs within a sequence of declaration specifiers within a function, method, or block.
IdentifierInfo *const * param_iterator
Parameters - The list of parameters for a function-like macro.
std::input_iterator_tag iterator_category
bool isFinalSpecified() const
A right parenthesis (')').
unsigned getFlags() const
getFlags - Return the flags for this scope.
Code completion where an Objective-C category name is expected.
static void AddStorageSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
Sema - This implements semantic analysis and AST building for C.
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
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...
Zero-argument (unary) selector.
DeclarationNameTable DeclarationNames
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
CandidateSetKind getKind() const
SmallVector< LambdaCapture, 4 > Captures
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
TST getTypeSpecType() const
iterator(const DeclIndexPair *Iterator)
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Code completion occurred where a protocol name is expected.
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Retains information about a block that is currently being parsed.
classprop_range class_properties() const
Type source information for an attributed type.
static bool InheritsFromClassNamed(ObjCInterfaceDecl *Class, StringRef Name)
Determine whether the given class is or inherits from a class by the given name.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
void CodeCompleteObjCMethodDecl(Scope *S, Optional< bool > IsInstanceMethod, ParsedType ReturnType)
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
QualType getPointeeType() const
Code completion occurred where a new name is expected.
Divide by this factor when a code-completion result's type is similar to the type we expect (e...
Represents a character-granular source range.
bool isVariadic() const
Whether this function is variadic.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
static PrintingPolicy getCompletionPrintingPolicy(const ASTContext &Context, const Preprocessor &PP)
const FunctionProtoType * T
Declaration of a template type parameter.
void CodeCompleteObjCPropertyDefinition(Scope *S)
DeclContext * getEntity() const
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
const T * castAs() const
Member-template castAs<specific type>.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool isTypeAltiVecVector() const
void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef< Expr *> Args)
static bool WantTypesInContext(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Code completion occurs within an Objective-C interface, protocol, or category.
Defines the clang::Preprocessor interface.
void CodeCompleteObjCAtVisibility(Scope *S)
overridden_method_range overridden_methods() const
bool isFileContext() const
An Objective-C @implementation for a category.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
bool isObjCClassType() const
DeclContext * getDeclContext()
CXXRecordDecl * getDefinition() const
ObjCInterfaceDecl * getSuperClass() const
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
A semicolon (';').
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
void CodeCompletePreprocessorExpression()
EnumDecl * getDefinition() const
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
ParmVarDecl *const * param_iterator
Code completion occurs within a statement, which may also be an expression or a declaration.
Captures a result of code completion.
Code completion occurred where a new name is expected and a qualified name is permissible.
A C++ class template partial specialization.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
bool isFunctionOrMethod() const
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
Priority for a member declaration found from the current method or member function.
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer *> Initializers)
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
An expression that sends a message to the given Objective-C object or class.
Code completion occurred in a context where natural language is expected, e.g., a comment or string l...
Divide by this factor when a code-completion result's type exactly matches the type we expect...
static std::string formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl, FunctionTypeLoc &Block, FunctionProtoTypeLoc &BlockProto, bool SuppressBlockName=false, bool SuppressBlock=false, Optional< ArrayRef< QualType >> ObjCSubsts=None)
Returns a placeholder string that corresponds to an Objective-C block declaration.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
bool isInstanceMethod() const
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Priority for a result that isn't likely to be what the user wants, but is included for completeness...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned getNumArgs() const
Selector getSelector() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
Code completion occurs within the list of instance variables in an Objective-C interface, protocol, category, or implementation.
void CodeCompleteNamespaceDecl(Scope *S)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
void CodeCompleteInitializer(Scope *S, Decl *D)
TypeLoc getReturnLoc() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
void CodeCompleteObjCPropertySetter(Scope *S)
static void AddObjCExpressionResults(ResultBuilder &Results, bool NeedAt)
The context in which code completion occurred, so that the code-completion consumer can process the r...
void CodeCompleteObjCAtExpression(Scope *S)
SourceManager & getSourceManager() const
void CodeCompleteTypeQualifiers(DeclSpec &DS)
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
The result is in a base class.
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
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.
void CodeCompleteObjCSelector(Scope *S, ArrayRef< IdentifierInfo *> SelIdents)
Code completion occurred within a class, struct, or union.
void CodeCompleteObjCAtDirective(Scope *S)
SelectorTable & Selectors
A C++ template type parameter.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
TypeLoc IgnoreParens() const
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ASTContext & getASTContext() const
Encodes a location in the source.
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo *> SelIdents, bool AtArgumentExpression, bool IsSuper, ResultBuilder &Results)
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
QualType getReturnType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Members, declared with object declarations within tag definitions.
decl_iterator decls_begin() const
const SwitchCase * getSwitchCaseList() const
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt)
pointer operator->() const
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
TagDecl - Represents the declaration of a struct/union/class/enum.
This is a scope that corresponds to the Objective-C @catch statement.
CodeCompletionString * CreateSignatureString(unsigned CurrentArg, Sema &S, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) const
Create a new code-completion string that describes the function signature of this overload candidate...
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
ASTContext & getASTContext() const LLVM_READONLY
static const TST TST_union
void CodeCompleteReturn(Scope *S)
Code completion where the name of an Objective-C class is expected.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Represents a static or instance method of a struct/union/class.
A field (in C) or non-static data member (in C++) in a struct, union, or C++ class.
Code completion occurred within an Objective-C interface, protocol, or category interface.
virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, OverloadCandidate *Candidates, unsigned NumCandidates)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void CodeCompleteOperatorName(Scope *S)
void CodeCompletePreprocessorDirective(bool InConditional)
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
const ParmVarDecl * getParamDecl(unsigned i) const
ObjCPropertyAttributeKind getPropertyAttributes() const
static void AddOverloadParameterChunks(ASTContext &Context, const PrintingPolicy &Policy, const FunctionDecl *Function, const FunctionProtoType *Prototype, CodeCompletionBuilder &Result, unsigned CurrentArg, unsigned Start=0, bool InOptional=false)
Add function overload parameter chunks to the given code completion string.
A right bracket (']').
ObjCCategoryDecl - Represents a category declaration.
static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S, Sema &SemaRef, ResultBuilder &Results)
Add language constructs that show up for "ordinary" names.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
bool isAnyPointerType() const
bool isObjCObjectPointerType() const
static void CodeCompleteOverloadResults(Sema &SemaRef, Scope *S, MutableArrayRef< ResultCandidate > Candidates, unsigned CurrentArg, bool CompleteExpressionWithCurrentArg=true)
Represents a C++11 virt-specifier-seq.
CodeCompleteConsumer * CodeCompleter
Code-completion consumer.
Represents one property declaration in an Objective-C interface.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
TypeClass getTypeClass() const
static void AddObjCVisibilityResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
ObjCDeclQualifier getObjCDeclQualifier() const
bool isC99Varargs() const
const ObjCMethodDecl * getMethodDecl() const
ObjCMethodKind
Describes the kind of Objective-C method that we want to find via code completion.
bool isStaticMember()
Returns true if this declares a static member.
const char * getBriefComment() const
static bool anyNullArguments(ArrayRef< Expr *> Args)
A left brace ('{').
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
ObjCImplementationDecl * getImplementation() const
llvm::SmallPtrSet< IdentifierInfo *, 16 > AddedPropertiesSet
The set of properties that have already been added, referenced by property name.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
void CodeCompletePreprocessorMacroName(bool IsDefinition)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addBriefComment(StringRef Comment)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
The injected class name of a C++ class template or class template partial specialization.
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
ObjCDeclQualifier getObjCDeclQualifier() const
StringRef getName() const
Return the actual identifier string.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
The scope of a struct/union/class definition.
ObjCIvarDecl * getNextIvar()
bool isMacroDefined(StringRef Id)
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...
Abstract interface for a consumer of code-completion information.
An Objective-C instance variable.
ParserCompletionContext
Describes the context in which code completion occurs.
Dataflow Directional Tag Classes.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
static const TSS TSS_unspecified
LambdaCaptureDefault Default
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
Code completion occurred where an macro is being defined.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
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...
bool isFunctionLike() const
The base class of all kinds of template declarations (e.g., class, function, etc.).
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< IdentifierInfo *> SelIdents)
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...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
A function or method parameter.
QualType getType() const
Get the type for which this source info wrapper provides information.
Priority for a send-to-super completion.
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name...
void CodeCompleteTag(Scope *S, unsigned TagSpec)
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
AccessSpecifier getAccess() const
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
This is a scope that corresponds to the template parameters of a C++ template.
Code completion occurred after the "union" keyword, to indicate a union name.
Code completion occurred where a macro name is expected (without any arguments, in the case of a func...
static void AddTypeQualifierResults(DeclSpec &DS, ResultBuilder &Results, const LangOptions &LangOpts)
A builder class used to construct new code-completion strings.
Code completion where an Objective-C instance message is expected.
DeclarationName - The name of a declaration.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
EnumDecl - Represents an enum.
static void addThisCompletion(Sema &S, ResultBuilder &Results)
Add a completion for "this", if we're in a member function.
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
static void HandleCodeCompleteResults(Sema *S, CodeCompleteConsumer *CodeCompleter, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
Priority for a constant value (e.g., enumerator).
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Code completion occurred where a statement (or declaration) is expected in a function, method, or block.
Code completion occurred on the right-hand side of an Objective-C property access expression...
All of the names in this module are visible.
static ObjCMethodDecl * AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword, ArrayRef< IdentifierInfo *> SelIdents, ResultBuilder &Results)
void CodeCompleteNamespaceAliasDecl(Scope *S)
unsigned getNumParams() const
static void FindImplementableMethods(ASTContext &Context, ObjCContainerDecl *Container, 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...
void CodeCompleteUsingDirective(Scope *S)
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Represents a pointer to an Objective C object.
SwitchStmt - This represents a 'switch' stmt.
Encapsulates the data about a macro definition (e.g.
bool SuppressUnwrittenScope
Suppress printing parts of scope specifiers that don't need to be written, e.g., for inline or anonym...
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Not an overloaded operator.
void AddInformativeChunk(const char *Text)
Add a new informative chunk.
const UnresolvedSetImpl & asUnresolvedSet() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, CodeCompletionBuilder &Result)
Add the name of the given declaration.
Priority for a preprocessor macro.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
A reference to a member of a struct, union, or class that occurs in some non-expression context...
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
A module import declaration.
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
A declaration whose specific kind is not exposed via this interface.
TypeSourceInfo * getTypeSourceInfo() const
A piece of text that describes the parameter that corresponds to the code-completion location within ...
void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar)
static const TST TST_typename
param_const_iterator param_begin() const
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
An Objective-C @dynamic definition.
void CodeCompleteObjCAtStatement(Scope *S)
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement)
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...
We are between inheritance colon and the real class/struct definition scope.
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited, bool IncludeDependentBases=false)
Capturing the *this object by reference.
An Objective-C class method.
void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, bool IsParameter)
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
friend bool operator!=(const iterator &X, const iterator &Y)
This is a scope that can contain a declaration.
SourceManager & getSourceManager()
bool isObjCObjectType() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
A left parenthesis ('(').
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
enum Kind getKind() const
Retrieve the kind of code-completion context.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
StringRef getParentName() const
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
const SwitchCase * getNextSwitchCase() const
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
Priority for a code pattern.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
QualType getParamType(unsigned i) const
TranslationUnitDecl * getTranslationUnitDecl() const
static bool isInstanceMethod(const Decl *D)
Captures information about "declaration specifiers".
Code completion occurs at the beginning of the initialization statement (or expression) in a for loop...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
An Objective-C @implementation.
CodeCompleteExpressionData(QualType PreferredType=QualType())
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...
sema::FunctionScopeInfo * getCurFunction() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS)
An unspecified code-completion context where we should also add macro completions.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
The parameter type of a method or function.
ObjCIvarDecl - Represents an ObjC instance variable.
A left angle bracket ('<').
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
void setCXXScopeSpecifier(CXXScopeSpec SS)
Sets the scope specifier that comes before the completion token.
A right angle bracket ('>').
bool isNull() const
Determine whether this is the empty selector.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Cursor that represents the translation unit itself.
Declaration of a class template.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
This class is used for builtin types like 'int'.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
ParsedType getRepAsType() const
void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
Vertical whitespace ('\n' or '\r\n', depending on the platform).
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
Represents a complete lambda introducer.
a linked list of methods with the same selector name but different signatures.
static std::string FormatFunctionParameter(const PrintingPolicy &Policy, const ParmVarDecl *Param, bool SuppressName=false, bool SuppressBlock=false, Optional< ArrayRef< QualType >> ObjCSubsts=None)
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
bool AnonymousTagLocations
When printing an anonymous tag name, also print the location of that entity (e.g., "enum <anonymous at t.h:10:5>").
static Qualifiers fromCVRMask(unsigned CVR)
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
static enum CodeCompletionContext::Kind mapCodeCompletionContext(Sema &S, Sema::ParserCompletionContext PCC)
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. ...
MacroMap::const_iterator macro_iterator
static OpaquePtr make(QualType P)
TranslationUnitDecl - The top declaration context.
static void AddObjCImplementationResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
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.
This declaration is a function-local extern declaration of a variable or function.
A reference to a declared variable, function, enum, etc.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
Code completion occurred on the right-hand side of a member access expression using the dot operator...
Represents a type template specialization; the template must be a class template, a type alias templa...
Code completion occurs within the condition of an if, while, switch, or for statement.
SimplifiedTypeClass
A simplified classification of types used when determining "similar" types for code completion...
static bool isNamespaceScope(Scope *S)
Determine whether this scope denotes a namespace.
void AddPlaceholderChunk(const char *Placeholder)
Add a new placeholder chunk.
static std::string GetDefaultValueString(const ParmVarDecl *Param, const SourceManager &SM, const LangOptions &LangOpts)
Code completion occurred where a type name is expected.
Horizontal whitespace (' ').
SourceManager & SourceMgr
void CodeCompleteObjCImplementationDecl(Scope *S)
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
static const TST TST_struct
void AddAnnotation(const char *A)
DeclaratorContext getContext() const
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
A trivial tuple used to represent a source range.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
static void mergeCandidatesWithResults(Sema &SemaRef, SmallVectorImpl< ResultCandidate > &Results, OverloadCandidateSet &CandidateSet, SourceLocation Loc)
ObjCMethodDecl * getGetterMethodDecl() const
NamedDecl - This represents a decl with a name.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
bool IntegralConstantExpression
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool isTranslationUnit() const
#define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword)
Macro that optionally prepends an "@" to the string literal passed in via Keyword, depending on whether NeedAt is true or false.
friend bool operator==(const iterator &X, const iterator &Y)
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
An Objective-C @interface.
A C++ conversion function.
const Expr * getCond() const
The receiver is a superclass.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void CodeCompleteAfterIf(Scope *S)
const LangOptions & getLangOpts() const
Wrapper for source info for block pointers.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
base_class_range vbases()
This class handles loading and caching of source files into memory.
Declaration of a template function.
Code completion occurs in a parenthesized expression, which might also be a type cast.
void CodeCompleteInPreprocessorConditionalExclusion(Scope *S)
void CodeCompleteObjCProtocolDecl(Scope *S)
SourceLocation getLocation() const
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
ArrayRef< ParmVarDecl * > parameters() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
decl_iterator decls_end() const
bool includeGlobals() const
Whether to include global (top-level) declaration results.
Priority for a non-type declaration.
Priority for the next initialization in a constructor initializer list.