26 #include "llvm/ADT/DenseSet.h"
27 #include "llvm/ADT/SmallBitVector.h"
28 #include "llvm/ADT/SmallPtrSet.h"
29 #include "llvm/ADT/SmallString.h"
30 #include "llvm/ADT/StringExtras.h"
31 #include "llvm/ADT/StringSwitch.h"
32 #include "llvm/ADT/Twine.h"
37 using namespace clang;
48 typedef bool (ResultBuilder::*LookupFilter)(
const NamedDecl *)
const;
54 std::vector<Result> Results;
59 llvm::SmallPtrSet<const Decl*, 16> AllDeclsFound;
61 typedef std::pair<const NamedDecl *, unsigned> DeclIndexPair;
66 class ShadowMapEntry {
71 llvm::PointerUnion<const NamedDecl *, DeclIndexPairVector*> DeclOrVector;
75 unsigned SingleDeclIndex;
78 ShadowMapEntry() : DeclOrVector(), SingleDeclIndex(0) { }
80 void Add(
const NamedDecl *ND,
unsigned Index) {
81 if (DeclOrVector.isNull()) {
84 SingleDeclIndex = Index;
89 DeclOrVector.dyn_cast<
const NamedDecl *>()) {
92 DeclIndexPairVector *Vec =
new DeclIndexPairVector;
93 Vec->push_back(DeclIndexPair(PrevND, SingleDeclIndex));
98 DeclOrVector.get<DeclIndexPairVector*>()->push_back(
99 DeclIndexPair(ND, Index));
103 if (DeclIndexPairVector *Vec
104 = DeclOrVector.dyn_cast<DeclIndexPairVector *>()) {
112 iterator begin()
const;
113 iterator end()
const;
119 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
136 bool AllowNestedNameSpecifiers;
147 std::list<ShadowMap> ShadowMaps;
154 bool HasObjectTypeQualifiers;
166 void AdjustResultPriorityForDecl(
Result &R);
168 void MaybeAddConstructorResults(
Result R);
174 LookupFilter Filter =
nullptr)
175 : SemaRef(SemaRef), Allocator(Allocator), CCTUInfo(CCTUInfo),
177 AllowNestedNameSpecifiers(
false), HasObjectTypeQualifiers(
false),
178 CompletionContext(CompletionContext),
179 ObjCImplementation(nullptr)
183 switch (CompletionContext.
getKind()) {
190 if (Method->isInstanceMethod())
192 ObjCImplementation = Interface->getImplementation();
201 unsigned getBasePriority(
const NamedDecl *D);
205 bool includeCodePatterns()
const {
211 void setFilter(LookupFilter Filter) {
212 this->Filter = Filter;
215 Result *data() {
return Results.empty()?
nullptr : &Results.front(); }
216 unsigned size()
const {
return Results.size(); }
217 bool empty()
const {
return Results.empty(); }
231 void setObjectTypeQualifiers(
Qualifiers Quals) {
232 ObjectTypeQualifiers = Quals;
233 HasObjectTypeQualifiers =
true;
241 void setPreferredSelector(
Selector Sel) {
242 PreferredSelector = Sel;
248 return CompletionContext;
252 void allowNestedNameSpecifiers(
bool Allow =
true) {
253 AllowNestedNameSpecifiers = Allow;
258 Sema &getSema()
const {
return SemaRef; }
272 bool isInterestingDecl(
const NamedDecl *ND,
273 bool &AsNestedNameSpecifier)
const;
311 void EnterNewScope();
325 bool IsOrdinaryName(
const NamedDecl *ND)
const;
326 bool IsOrdinaryNonTypeName(
const NamedDecl *ND)
const;
327 bool IsIntegralConstantValue(
const NamedDecl *ND)
const;
328 bool IsOrdinaryNonValueName(
const NamedDecl *ND)
const;
329 bool IsNestedNameSpecifier(
const NamedDecl *ND)
const;
331 bool IsClassOrStruct(
const NamedDecl *ND)
const;
333 bool IsNamespace(
const NamedDecl *ND)
const;
334 bool IsNamespaceOrAlias(
const NamedDecl *ND)
const;
336 bool IsMember(
const NamedDecl *ND)
const;
337 bool IsObjCIvar(
const NamedDecl *ND)
const;
338 bool IsObjCMessageReceiver(
const NamedDecl *ND)
const;
339 bool IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const;
340 bool IsObjCCollection(
const NamedDecl *ND)
const;
341 bool IsImpossibleToSatisfy(
const NamedDecl *ND)
const;
347 llvm::PointerUnion<const NamedDecl *, const DeclIndexPair *> DeclOrIterator;
348 unsigned SingleDeclIndex;
370 : DeclOrIterator(SingleDecl), SingleDeclIndex(Index) { }
373 : DeclOrIterator(Iterator), SingleDeclIndex(0) { }
376 if (DeclOrIterator.is<
const NamedDecl *>()) {
382 const DeclIndexPair *
I = DeclOrIterator.get<
const DeclIndexPair*>();
398 return *DeclOrIterator.get<
const DeclIndexPair*>();
406 return X.DeclOrIterator.getOpaqueValue()
407 == Y.DeclOrIterator.getOpaqueValue() &&
408 X.SingleDeclIndex == Y.SingleDeclIndex;
417 ResultBuilder::ShadowMapEntry::begin()
const {
418 if (DeclOrVector.isNull())
422 return iterator(ND, SingleDeclIndex);
424 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->begin());
428 ResultBuilder::ShadowMapEntry::end()
const {
429 if (DeclOrVector.is<
const NamedDecl *>() || DeclOrVector.isNull())
432 return iterator(DeclOrVector.get<DeclIndexPairVector *>()->end());
454 for (
const DeclContext *CommonAncestor = TargetContext;
455 CommonAncestor && !CommonAncestor->
Encloses(CurContext);
456 CommonAncestor = CommonAncestor->getLookupParent()) {
457 if (CommonAncestor->isTransparentContext() ||
458 CommonAncestor->isFunctionOrMethod())
461 TargetParents.push_back(CommonAncestor);
465 while (!TargetParents.empty()) {
466 const DeclContext *Parent = TargetParents.pop_back_val();
468 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Parent)) {
469 if (!Namespace->getIdentifier())
474 else if (
const TagDecl *TD = dyn_cast<TagDecl>(Parent))
485 bool doubleUnderscoreOnly =
false) {
489 return Name[0] ==
'_' &&
490 (Name[1] ==
'_' || (Name[1] >=
'A' && Name[1] <=
'Z' &&
491 !doubleUnderscoreOnly));
517 bool ResultBuilder::isInterestingDecl(
const NamedDecl *ND,
518 bool &AsNestedNameSpecifier)
const {
519 AsNestedNameSpecifier =
false;
534 if (isa<ClassTemplateSpecializationDecl>(ND) ||
535 isa<ClassTemplatePartialSpecializationDecl>(ND))
539 if (isa<UsingDecl>(ND))
545 if (Filter == &ResultBuilder::IsNestedNameSpecifier ||
546 (isa<NamespaceDecl>(ND) &&
547 Filter != &ResultBuilder::IsNamespace &&
548 Filter != &ResultBuilder::IsNamespaceOrAlias &&
550 AsNestedNameSpecifier =
true;
553 if (Filter && !(this->*Filter)(Named)) {
555 if (AllowNestedNameSpecifiers && SemaRef.
getLangOpts().CPlusPlus &&
556 IsNestedNameSpecifier(ND) &&
557 (Filter != &ResultBuilder::IsMember ||
558 (isa<CXXRecordDecl>(ND) &&
559 cast<CXXRecordDecl>(ND)->isInjectedClassName()))) {
560 AsNestedNameSpecifier =
true;
570 bool ResultBuilder::CheckHiddenResult(Result &R,
DeclContext *CurContext,
590 R.QualifierIsInformative =
false;
595 R.Declaration->getDeclContext());
602 switch (T->getTypeClass()) {
604 switch (cast<BuiltinType>(T)->getKind()) {
605 case BuiltinType::Void:
608 case BuiltinType::NullPtr:
611 case BuiltinType::Overload:
612 case BuiltinType::Dependent:
615 case BuiltinType::ObjCId:
616 case BuiltinType::ObjCClass:
617 case BuiltinType::ObjCSel:
630 case Type::BlockPointer:
633 case Type::LValueReference:
634 case Type::RValueReference:
637 case Type::ConstantArray:
638 case Type::IncompleteArray:
639 case Type::VariableArray:
640 case Type::DependentSizedArray:
643 case Type::DependentSizedExtVector:
645 case Type::ExtVector:
648 case Type::FunctionProto:
649 case Type::FunctionNoProto:
658 case Type::ObjCObject:
659 case Type::ObjCInterface:
660 case Type::ObjCObjectPointer:
680 T = Function->getCallResultType();
681 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND))
682 T = Method->getSendResultType();
683 else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
688 T =
Value->getType();
702 if (Pointer->getPointeeType()->isFunctionType()) {
716 T = Function->getReturnType();
726 unsigned ResultBuilder::getBasePriority(
const NamedDecl *ND) {
735 dyn_cast<ImplicitParamDecl>(ND))
736 if (ImplicitParam->getIdentifier() &&
737 ImplicitParam->getIdentifier()->isStr(
"_cmd"))
744 if (DC->
isRecord() || isa<ObjCContainerDecl>(DC))
748 if (isa<EnumConstantDecl>(ND))
754 if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) &&
765 void ResultBuilder::AdjustResultPriorityForDecl(Result &R) {
768 if (!PreferredSelector.isNull())
769 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(R.Declaration))
770 if (PreferredSelector == Method->getSelector())
775 if (!PreferredType.isNull()) {
785 !(PreferredType->isEnumeralType() && TC->isEnumeralType()))
791 void ResultBuilder::MaybeAddConstructorResults(Result R) {
792 if (!SemaRef.
getLangOpts().CPlusPlus || !R.Declaration ||
800 Record = ClassTemplate->getTemplatedDecl();
801 else if ((Record = dyn_cast<CXXRecordDecl>(D))) {
803 if (isa<ClassTemplateSpecializationDecl>(Record))
825 Results.push_back(R);
829 void ResultBuilder::MaybeAddResult(Result R,
DeclContext *CurContext) {
830 assert(!ShadowMaps.empty() &&
"Must enter into a results scope");
832 if (R.Kind != Result::RK_Declaration) {
834 Results.push_back(R);
840 dyn_cast<UsingShadowDecl>(R.Declaration)) {
841 MaybeAddResult(
Result(Using->getTargetDecl(),
842 getBasePriority(Using->getTargetDecl()),
851 bool AsNestedNameSpecifier =
false;
852 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
856 if (isa<CXXConstructorDecl>(R.Declaration))
859 ShadowMap &
SMap = ShadowMaps.back();
860 ShadowMapEntry::iterator
I, IEnd;
861 ShadowMap::iterator NamePos = SMap.find(R.Declaration->getDeclName());
862 if (NamePos != SMap.end()) {
863 I = NamePos->second.begin();
864 IEnd = NamePos->second.end();
867 for (; I != IEnd; ++
I) {
869 unsigned Index = I->second;
872 Results[Index].Declaration = R.Declaration;
882 std::list<ShadowMap>::iterator
SM, SMEnd = ShadowMaps.end();
884 for (SM = ShadowMaps.begin(); SM != SMEnd; ++
SM) {
885 ShadowMapEntry::iterator
I, IEnd;
886 ShadowMap::iterator NamePos = SM->find(R.Declaration->getDeclName());
887 if (NamePos != SM->end()) {
888 I = NamePos->second.begin();
889 IEnd = NamePos->second.end();
891 for (; I != IEnd; ++
I) {
893 if (I->first->hasTagIdentifierNamespace() &&
901 I->first->getIdentifierNamespace() != IDNS)
905 if (CheckHiddenResult(R, CurContext, I->first))
913 if (!AllDeclsFound.insert(CanonDecl).second)
918 if (AsNestedNameSpecifier) {
919 R.StartsNestedNameSpecifier =
true;
922 AdjustResultPriorityForDecl(R);
925 if (R.QualifierIsInformative && !R.Qualifier &&
926 !R.StartsNestedNameSpecifier) {
927 const DeclContext *Ctx = R.Declaration->getDeclContext();
928 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
931 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
935 R.QualifierIsInformative =
false;
940 SMap[R.Declaration->getDeclName()].Add(R.Declaration, Results.size());
941 Results.push_back(R);
943 if (!AsNestedNameSpecifier)
944 MaybeAddConstructorResults(R);
947 void ResultBuilder::AddResult(Result R,
DeclContext *CurContext,
948 NamedDecl *Hiding,
bool InBaseClass =
false) {
949 if (R.Kind != Result::RK_Declaration) {
951 Results.push_back(R);
956 if (
const UsingShadowDecl *Using = dyn_cast<UsingShadowDecl>(R.Declaration)) {
957 AddResult(
Result(Using->getTargetDecl(),
958 getBasePriority(Using->getTargetDecl()),
964 bool AsNestedNameSpecifier =
false;
965 if (!isInterestingDecl(R.Declaration, AsNestedNameSpecifier))
969 if (isa<CXXConstructorDecl>(R.Declaration))
972 if (Hiding && CheckHiddenResult(R, CurContext, Hiding))
976 if (!AllDeclsFound.insert(R.Declaration->getCanonicalDecl()).second)
981 if (AsNestedNameSpecifier) {
982 R.StartsNestedNameSpecifier =
true;
985 else if (Filter == &ResultBuilder::IsMember && !R.Qualifier && InBaseClass &&
986 isa<CXXRecordDecl>(R.Declaration->getDeclContext()
987 ->getRedeclContext()))
988 R.QualifierIsInformative =
true;
991 if (R.QualifierIsInformative && !R.Qualifier &&
992 !R.StartsNestedNameSpecifier) {
993 const DeclContext *Ctx = R.Declaration->getDeclContext();
994 if (
const NamespaceDecl *Namespace = dyn_cast<NamespaceDecl>(Ctx))
997 else if (
const TagDecl *Tag = dyn_cast<TagDecl>(Ctx))
1001 R.QualifierIsInformative =
false;
1008 AdjustResultPriorityForDecl(R);
1010 if (HasObjectTypeQualifiers)
1011 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(R.Declaration))
1012 if (Method->isInstance()) {
1015 if (ObjectTypeQualifiers == MethodQuals)
1017 else if (ObjectTypeQualifiers - MethodQuals) {
1025 Results.push_back(R);
1027 if (!AsNestedNameSpecifier)
1028 MaybeAddConstructorResults(R);
1031 void ResultBuilder::AddResult(Result R) {
1032 assert(R.Kind != Result::RK_Declaration &&
1033 "Declaration results need more context");
1034 Results.push_back(R);
1038 void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
1041 void ResultBuilder::ExitScope() {
1042 for (ShadowMap::iterator
E = ShadowMaps.back().begin(),
1043 EEnd = ShadowMaps.back().end();
1046 E->second.Destroy();
1048 ShadowMaps.pop_back();
1053 bool ResultBuilder::IsOrdinaryName(
const NamedDecl *ND)
const {
1062 if (isa<ObjCIvarDecl>(ND))
1071 bool ResultBuilder::IsOrdinaryNonTypeName(
const NamedDecl *ND)
const {
1073 if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND))
1080 if (isa<ObjCIvarDecl>(ND))
1087 bool ResultBuilder::IsIntegralConstantValue(
const NamedDecl *ND)
const {
1088 if (!IsOrdinaryNonTypeName(ND))
1092 if (VD->getType()->isIntegralOrEnumerationType())
1100 bool ResultBuilder::IsOrdinaryNonValueName(
const NamedDecl *ND)
const {
1108 !isa<ValueDecl>(ND) && !isa<FunctionTemplateDecl>(ND) &&
1109 !isa<ObjCPropertyDecl>(ND);
1114 bool ResultBuilder::IsNestedNameSpecifier(
const NamedDecl *ND)
const {
1117 ND = ClassTemplate->getTemplatedDecl();
1123 bool ResultBuilder::IsEnum(
const NamedDecl *ND)
const {
1124 return isa<EnumDecl>(ND);
1128 bool ResultBuilder::IsClassOrStruct(
const NamedDecl *ND)
const {
1131 ND = ClassTemplate->getTemplatedDecl();
1134 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1143 bool ResultBuilder::IsUnion(
const NamedDecl *ND)
const {
1146 ND = ClassTemplate->getTemplatedDecl();
1148 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(ND))
1155 bool ResultBuilder::IsNamespace(
const NamedDecl *ND)
const {
1156 return isa<NamespaceDecl>(ND);
1161 bool ResultBuilder::IsNamespaceOrAlias(
const NamedDecl *ND)
const {
1166 bool ResultBuilder::IsType(
const NamedDecl *ND)
const {
1168 return isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1174 bool ResultBuilder::IsMember(
const NamedDecl *ND)
const {
1176 return isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
1177 isa<ObjCPropertyDecl>(ND);
1183 case Type::ObjCObject:
1184 case Type::ObjCInterface:
1185 case Type::ObjCObjectPointer:
1189 switch (cast<BuiltinType>(T)->getKind()) {
1190 case BuiltinType::ObjCId:
1191 case BuiltinType::ObjCClass:
1192 case BuiltinType::ObjCSel:
1213 bool ResultBuilder::IsObjCMessageReceiver(
const NamedDecl *ND)
const {
1222 bool ResultBuilder::IsObjCMessageReceiverOrLambdaCapture(
const NamedDecl *ND)
const {
1223 if (IsObjCMessageReceiver(ND))
1233 bool ResultBuilder::IsObjCCollection(
const NamedDecl *ND)
const {
1234 if ((SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryName(ND)) ||
1235 (!SemaRef.
getLangOpts().CPlusPlus && !IsOrdinaryNonTypeName(ND)))
1248 bool ResultBuilder::IsImpossibleToSatisfy(
const NamedDecl *ND)
const {
1254 bool ResultBuilder::IsObjCIvar(
const NamedDecl *ND)
const {
1255 return isa<ObjCIvarDecl>(ND);
1262 ResultBuilder &Results;
1266 CodeCompletionDeclConsumer(ResultBuilder &Results,
DeclContext *CurContext)
1267 : Results(Results), CurContext(CurContext) { }
1270 bool InBaseClass)
override {
1271 bool Accessible =
true;
1273 Accessible = Results.getSema().IsSimplyAccessible(ND, Ctx);
1277 Results.AddResult(Result, CurContext, Hiding, InBaseClass);
1284 ResultBuilder &Results) {
1286 Results.AddResult(Result(
"short",
CCP_Type));
1287 Results.AddResult(Result(
"long",
CCP_Type));
1288 Results.AddResult(Result(
"signed",
CCP_Type));
1289 Results.AddResult(Result(
"unsigned",
CCP_Type));
1290 Results.AddResult(Result(
"void",
CCP_Type));
1291 Results.AddResult(Result(
"char",
CCP_Type));
1292 Results.AddResult(Result(
"int",
CCP_Type));
1293 Results.AddResult(Result(
"float",
CCP_Type));
1294 Results.AddResult(Result(
"double",
CCP_Type));
1295 Results.AddResult(Result(
"enum",
CCP_Type));
1296 Results.AddResult(Result(
"struct",
CCP_Type));
1297 Results.AddResult(Result(
"union",
CCP_Type));
1298 Results.AddResult(Result(
"const",
CCP_Type));
1299 Results.AddResult(Result(
"volatile",
CCP_Type));
1303 Results.AddResult(Result(
"_Complex",
CCP_Type));
1304 Results.AddResult(Result(
"_Imaginary",
CCP_Type));
1305 Results.AddResult(Result(
"_Bool",
CCP_Type));
1306 Results.AddResult(Result(
"restrict",
CCP_Type));
1310 Results.getCodeCompletionTUInfo());
1311 if (LangOpts.CPlusPlus) {
1313 Results.AddResult(Result(
"bool",
CCP_Type +
1315 Results.AddResult(Result(
"class",
CCP_Type));
1316 Results.AddResult(Result(
"wchar_t",
CCP_Type));
1319 Builder.AddTypedTextChunk(
"typename");
1321 Builder.AddPlaceholderChunk(
"qualifier");
1323 Builder.AddPlaceholderChunk(
"name");
1324 Results.AddResult(Result(
Builder.TakeString()));
1326 if (LangOpts.CPlusPlus11) {
1327 Results.AddResult(Result(
"auto",
CCP_Type));
1328 Results.AddResult(Result(
"char16_t",
CCP_Type));
1329 Results.AddResult(Result(
"char32_t",
CCP_Type));
1331 Builder.AddTypedTextChunk(
"decltype");
1333 Builder.AddPlaceholderChunk(
"expression");
1335 Results.AddResult(Result(
Builder.TakeString()));
1338 Results.AddResult(Result(
"__auto_type",
CCP_Type));
1341 if (LangOpts.GNUMode) {
1347 Builder.AddTypedTextChunk(
"typeof");
1349 Builder.AddPlaceholderChunk(
"expression");
1350 Results.AddResult(Result(
Builder.TakeString()));
1352 Builder.AddTypedTextChunk(
"typeof");
1354 Builder.AddPlaceholderChunk(
"type");
1356 Results.AddResult(Result(
Builder.TakeString()));
1360 Results.AddResult(Result(
"_Nonnull",
CCP_Type));
1361 Results.AddResult(Result(
"_Null_unspecified",
CCP_Type));
1362 Results.AddResult(Result(
"_Nullable",
CCP_Type));
1367 ResultBuilder &Results) {
1372 Results.AddResult(Result(
"extern"));
1373 Results.AddResult(Result(
"static"));
1375 if (LangOpts.CPlusPlus11) {
1380 Builder.AddTypedTextChunk(
"alignas");
1382 Builder.AddPlaceholderChunk(
"expression");
1384 Results.AddResult(Result(
Builder.TakeString()));
1386 Results.AddResult(Result(
"constexpr"));
1387 Results.AddResult(Result(
"thread_local"));
1393 ResultBuilder &Results) {
1398 if (LangOpts.CPlusPlus) {
1399 Results.AddResult(Result(
"explicit"));
1400 Results.AddResult(Result(
"friend"));
1401 Results.AddResult(Result(
"mutable"));
1402 Results.AddResult(Result(
"virtual"));
1410 if (LangOpts.CPlusPlus || LangOpts.C99)
1411 Results.AddResult(Result(
"inline"));
1430 ResultBuilder &Results,
1433 ResultBuilder &Results,
1436 ResultBuilder &Results,
1442 Results.getCodeCompletionTUInfo());
1443 Builder.AddTypedTextChunk(
"typedef");
1445 Builder.AddPlaceholderChunk(
"type");
1447 Builder.AddPlaceholderChunk(
"name");
1468 return LangOpts.CPlusPlus;
1475 return LangOpts.CPlusPlus || LangOpts.ObjC1 || LangOpts.C99;
1478 llvm_unreachable(
"Invalid ParserCompletionContext!");
1506 if (
const BuiltinType *BT = dyn_cast<BuiltinType>(T))
1507 return BT->getNameAsCString(Policy);
1510 if (
const TagType *TagT = dyn_cast<TagType>(T))
1511 if (
TagDecl *Tag = TagT->getDecl())
1512 if (!Tag->hasNameForLinkage()) {
1513 switch (Tag->getTagKind()) {
1514 case TTK_Struct:
return "struct <anonymous>";
1516 case TTK_Class:
return "class <anonymous>";
1517 case TTK_Union:
return "union <anonymous>";
1518 case TTK_Enum:
return "enum <anonymous>";
1542 Builder.AddTypedTextChunk(
"this");
1547 ResultBuilder &Results,
1549 if (!LangOpts.CPlusPlus11)
1565 ResultBuilder &Results) {
1573 if (Results.includeCodePatterns()) {
1575 Builder.AddTypedTextChunk(
"namespace");
1577 Builder.AddPlaceholderChunk(
"identifier");
1579 Builder.AddPlaceholderChunk(
"declarations");
1582 Results.AddResult(Result(
Builder.TakeString()));
1586 Builder.AddTypedTextChunk(
"namespace");
1588 Builder.AddPlaceholderChunk(
"name");
1590 Builder.AddPlaceholderChunk(
"namespace");
1591 Results.AddResult(Result(
Builder.TakeString()));
1594 Builder.AddTypedTextChunk(
"using");
1596 Builder.AddTextChunk(
"namespace");
1598 Builder.AddPlaceholderChunk(
"identifier");
1599 Results.AddResult(Result(
Builder.TakeString()));
1602 Builder.AddTypedTextChunk(
"asm");
1604 Builder.AddPlaceholderChunk(
"string-literal");
1606 Results.AddResult(Result(
Builder.TakeString()));
1608 if (Results.includeCodePatterns()) {
1610 Builder.AddTypedTextChunk(
"template");
1612 Builder.AddPlaceholderChunk(
"declaration");
1613 Results.AddResult(Result(
Builder.TakeString()));
1626 Builder.AddTypedTextChunk(
"using");
1628 Builder.AddPlaceholderChunk(
"qualifier");
1630 Builder.AddPlaceholderChunk(
"name");
1631 Results.AddResult(Result(
Builder.TakeString()));
1635 Builder.AddTypedTextChunk(
"using");
1637 Builder.AddTextChunk(
"typename");
1639 Builder.AddPlaceholderChunk(
"qualifier");
1641 Builder.AddPlaceholderChunk(
"name");
1642 Results.AddResult(Result(
Builder.TakeString()));
1651 Builder.AddTypedTextChunk(
"public");
1652 if (Results.includeCodePatterns())
1654 Results.AddResult(Result(
Builder.TakeString()));
1657 Builder.AddTypedTextChunk(
"protected");
1658 if (Results.includeCodePatterns())
1660 Results.AddResult(Result(
Builder.TakeString()));
1663 Builder.AddTypedTextChunk(
"private");
1664 if (Results.includeCodePatterns())
1666 Results.AddResult(Result(
Builder.TakeString()));
1673 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns()) {
1675 Builder.AddTypedTextChunk(
"template");
1677 Builder.AddPlaceholderChunk(
"parameters");
1679 Results.AddResult(Result(
Builder.TakeString()));
1706 if (SemaRef.
getLangOpts().CPlusPlus && Results.includeCodePatterns() &&
1708 Builder.AddTypedTextChunk(
"try");
1710 Builder.AddPlaceholderChunk(
"statements");
1713 Builder.AddTextChunk(
"catch");
1715 Builder.AddPlaceholderChunk(
"declaration");
1718 Builder.AddPlaceholderChunk(
"statements");
1721 Results.AddResult(Result(
Builder.TakeString()));
1726 if (Results.includeCodePatterns()) {
1728 Builder.AddTypedTextChunk(
"if");
1731 Builder.AddPlaceholderChunk(
"condition");
1733 Builder.AddPlaceholderChunk(
"expression");
1736 Builder.AddPlaceholderChunk(
"statements");
1739 Results.AddResult(Result(
Builder.TakeString()));
1742 Builder.AddTypedTextChunk(
"switch");
1745 Builder.AddPlaceholderChunk(
"condition");
1747 Builder.AddPlaceholderChunk(
"expression");
1752 Results.AddResult(Result(
Builder.TakeString()));
1758 Builder.AddTypedTextChunk(
"case");
1760 Builder.AddPlaceholderChunk(
"expression");
1762 Results.AddResult(Result(
Builder.TakeString()));
1765 Builder.AddTypedTextChunk(
"default");
1767 Results.AddResult(Result(
Builder.TakeString()));
1770 if (Results.includeCodePatterns()) {
1772 Builder.AddTypedTextChunk(
"while");
1775 Builder.AddPlaceholderChunk(
"condition");
1777 Builder.AddPlaceholderChunk(
"expression");
1780 Builder.AddPlaceholderChunk(
"statements");
1783 Results.AddResult(Result(
Builder.TakeString()));
1786 Builder.AddTypedTextChunk(
"do");
1788 Builder.AddPlaceholderChunk(
"statements");
1791 Builder.AddTextChunk(
"while");
1793 Builder.AddPlaceholderChunk(
"expression");
1795 Results.AddResult(Result(
Builder.TakeString()));
1798 Builder.AddTypedTextChunk(
"for");
1801 Builder.AddPlaceholderChunk(
"init-statement");
1803 Builder.AddPlaceholderChunk(
"init-expression");
1805 Builder.AddPlaceholderChunk(
"condition");
1807 Builder.AddPlaceholderChunk(
"inc-expression");
1811 Builder.AddPlaceholderChunk(
"statements");
1814 Results.AddResult(Result(
Builder.TakeString()));
1819 Builder.AddTypedTextChunk(
"continue");
1820 Results.AddResult(Result(
Builder.TakeString()));
1825 Builder.AddTypedTextChunk(
"break");
1826 Results.AddResult(Result(
Builder.TakeString()));
1831 bool isVoid =
false;
1833 isVoid = Function->getReturnType()->isVoidType();
1835 = dyn_cast<ObjCMethodDecl>(SemaRef.
CurContext))
1836 isVoid = Method->getReturnType()->isVoidType();
1840 Builder.AddTypedTextChunk(
"return");
1843 Builder.AddPlaceholderChunk(
"expression");
1845 Results.AddResult(Result(
Builder.TakeString()));
1848 Builder.AddTypedTextChunk(
"goto");
1850 Builder.AddPlaceholderChunk(
"label");
1851 Results.AddResult(Result(
Builder.TakeString()));
1854 Builder.AddTypedTextChunk(
"using");
1856 Builder.AddTextChunk(
"namespace");
1858 Builder.AddPlaceholderChunk(
"identifier");
1859 Results.AddResult(Result(
Builder.TakeString()));
1876 Builder.AddTypedTextChunk(
"__bridge");
1878 Builder.AddPlaceholderChunk(
"type");
1880 Builder.AddPlaceholderChunk(
"expression");
1881 Results.AddResult(Result(
Builder.TakeString()));
1884 Builder.AddTypedTextChunk(
"__bridge_transfer");
1886 Builder.AddPlaceholderChunk(
"Objective-C type");
1888 Builder.AddPlaceholderChunk(
"expression");
1889 Results.AddResult(Result(
Builder.TakeString()));
1892 Builder.AddTypedTextChunk(
"__bridge_retained");
1894 Builder.AddPlaceholderChunk(
"CF type");
1896 Builder.AddPlaceholderChunk(
"expression");
1897 Results.AddResult(Result(
Builder.TakeString()));
1908 Builder.AddResultTypeChunk(
"bool");
1909 Builder.AddTypedTextChunk(
"true");
1910 Results.AddResult(Result(
Builder.TakeString()));
1913 Builder.AddResultTypeChunk(
"bool");
1914 Builder.AddTypedTextChunk(
"false");
1915 Results.AddResult(Result(
Builder.TakeString()));
1919 Builder.AddTypedTextChunk(
"dynamic_cast");
1921 Builder.AddPlaceholderChunk(
"type");
1924 Builder.AddPlaceholderChunk(
"expression");
1926 Results.AddResult(Result(
Builder.TakeString()));
1930 Builder.AddTypedTextChunk(
"static_cast");
1932 Builder.AddPlaceholderChunk(
"type");
1935 Builder.AddPlaceholderChunk(
"expression");
1937 Results.AddResult(Result(
Builder.TakeString()));
1940 Builder.AddTypedTextChunk(
"reinterpret_cast");
1942 Builder.AddPlaceholderChunk(
"type");
1945 Builder.AddPlaceholderChunk(
"expression");
1947 Results.AddResult(Result(
Builder.TakeString()));
1950 Builder.AddTypedTextChunk(
"const_cast");
1952 Builder.AddPlaceholderChunk(
"type");
1955 Builder.AddPlaceholderChunk(
"expression");
1957 Results.AddResult(Result(
Builder.TakeString()));
1961 Builder.AddResultTypeChunk(
"std::type_info");
1962 Builder.AddTypedTextChunk(
"typeid");
1964 Builder.AddPlaceholderChunk(
"expression-or-type");
1966 Results.AddResult(Result(
Builder.TakeString()));
1970 Builder.AddTypedTextChunk(
"new");
1972 Builder.AddPlaceholderChunk(
"type");
1974 Builder.AddPlaceholderChunk(
"expressions");
1976 Results.AddResult(Result(
Builder.TakeString()));
1979 Builder.AddTypedTextChunk(
"new");
1981 Builder.AddPlaceholderChunk(
"type");
1983 Builder.AddPlaceholderChunk(
"size");
1986 Builder.AddPlaceholderChunk(
"expressions");
1988 Results.AddResult(Result(
Builder.TakeString()));
1991 Builder.AddResultTypeChunk(
"void");
1992 Builder.AddTypedTextChunk(
"delete");
1994 Builder.AddPlaceholderChunk(
"expression");
1995 Results.AddResult(Result(
Builder.TakeString()));
1998 Builder.AddResultTypeChunk(
"void");
1999 Builder.AddTypedTextChunk(
"delete");
2004 Builder.AddPlaceholderChunk(
"expression");
2005 Results.AddResult(Result(
Builder.TakeString()));
2009 Builder.AddResultTypeChunk(
"void");
2010 Builder.AddTypedTextChunk(
"throw");
2012 Builder.AddPlaceholderChunk(
"expression");
2013 Results.AddResult(Result(
Builder.TakeString()));
2020 Builder.AddResultTypeChunk(
"std::nullptr_t");
2021 Builder.AddTypedTextChunk(
"nullptr");
2022 Results.AddResult(Result(
Builder.TakeString()));
2025 Builder.AddResultTypeChunk(
"size_t");
2026 Builder.AddTypedTextChunk(
"alignof");
2028 Builder.AddPlaceholderChunk(
"type");
2030 Results.AddResult(Result(
Builder.TakeString()));
2033 Builder.AddResultTypeChunk(
"bool");
2034 Builder.AddTypedTextChunk(
"noexcept");
2036 Builder.AddPlaceholderChunk(
"expression");
2038 Results.AddResult(Result(
Builder.TakeString()));
2041 Builder.AddResultTypeChunk(
"size_t");
2042 Builder.AddTypedTextChunk(
"sizeof...");
2044 Builder.AddPlaceholderChunk(
"parameter-pack");
2046 Results.AddResult(Result(
Builder.TakeString()));
2055 if (
ID->getSuperClass()) {
2056 std::string SuperType;
2057 SuperType =
ID->getSuperClass()->getNameAsString();
2058 if (Method->isInstanceMethod())
2062 Builder.AddTypedTextChunk(
"super");
2063 Results.AddResult(Result(
Builder.TakeString()));
2072 Builder.AddResultTypeChunk(
"size_t");
2074 Builder.AddTypedTextChunk(
"alignof");
2076 Builder.AddTypedTextChunk(
"_Alignof");
2078 Builder.AddPlaceholderChunk(
"type");
2080 Results.AddResult(Result(
Builder.TakeString()));
2084 Builder.AddResultTypeChunk(
"size_t");
2085 Builder.AddTypedTextChunk(
"sizeof");
2087 Builder.AddPlaceholderChunk(
"expression-or-type");
2089 Results.AddResult(Result(
Builder.TakeString()));
2102 Results.AddResult(Result(
"operator"));
2117 if (isa<CXXConstructorDecl>(ND) || isa<CXXConversionDecl>(ND))
2123 T = Function->getReturnType();
2124 else if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2126 T = Method->getSendResultType(BaseType);
2128 T = Method->getReturnType();
2129 }
else if (
const EnumConstantDecl *Enumerator = dyn_cast<EnumConstantDecl>(ND))
2130 T = Context.
getTypeDeclType(cast<TypeDecl>(Enumerator->getDeclContext()));
2131 else if (isa<UnresolvedUsingValueDecl>(ND)) {
2133 }
else if (
const ObjCIvarDecl *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
2135 T = Ivar->getUsageType(BaseType);
2137 T = Ivar->getType();
2139 T =
Value->getType();
2142 T =
Property->getUsageType(BaseType);
2157 if (SentinelAttr *Sentinel = FunctionOrMethod->
getAttr<SentinelAttr>())
2158 if (Sentinel->getSentinel() == 0) {
2178 Result +=
"bycopy ";
2182 Result +=
"oneway ";
2185 switch (*nullability) {
2187 Result +=
"nonnull ";
2191 Result +=
"nullable ";
2195 Result +=
"null_unspecified ";
2212 bool SuppressBlock =
false) {
2218 if (!SuppressBlock) {
2221 TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) {
2234 TL = AttrTL.getModifiedLoc();
2253 bool SuppressBlockName =
false,
2254 bool SuppressBlock =
false,
2255 Optional<ArrayRef<QualType>> ObjCSubsts = None);
2259 bool SuppressName =
false,
2260 bool SuppressBlock =
false,
2261 Optional<ArrayRef<QualType>> ObjCSubsts = None) {
2262 bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->
getDeclContext());
2269 if (Param->
getIdentifier() && !ObjCMethodParam && !SuppressName)
2276 if (ObjCMethodParam) {
2296 if (!Block && ObjCMethodParam &&
2297 cast<ObjCMethodDecl>(Param->
getDeclContext())->isPropertyAccessor()) {
2298 if (
const auto *PD = cast<ObjCMethodDecl>(Param->
getDeclContext())
2299 ->findPropertyDecl(
false))
2313 if (ObjCMethodParam) {
2318 Result =
"(" + Quals +
" " + Result +
")";
2319 if (Result.back() !=
')')
2333 false, SuppressBlock,
2349 bool SuppressBlockName,
bool SuppressBlock,
2350 Optional<ArrayRef<QualType>> ObjCSubsts) {
2357 if (!ResultType->
isVoidType() || SuppressBlock)
2369 for (
unsigned I = 0, N = Block.
getNumParams(); I != N; ++
I) {
2382 if (SuppressBlock) {
2384 Result = Result +
" (^";
2391 Result =
'^' + Result;
2406 bool Invalid = CharSrcRange.
isInvalid();
2413 if (srcText.empty() || srcText ==
"=") {
2418 std::string DefValue(srcText.str());
2421 if (DefValue.at(0) !=
'=') {
2424 return " = " + DefValue;
2426 return " " + DefValue;
2435 bool InOptional =
false) {
2436 bool FirstParameter =
true;
2446 if (!FirstParameter)
2454 FirstParameter =
false;
2466 PlaceholderStr +=
", ...";
2475 if (Proto->isVariadic()) {
2476 if (Proto->getNumParams() == 0)
2488 unsigned MaxParameters = 0,
2490 bool InDefaultArg =
false) {
2491 bool FirstParameter =
true;
2500 PEnd = Params->begin() + MaxParameters;
2503 bool HasDefaultArg =
false;
2504 std::string PlaceholderStr;
2506 if (TTP->wasDeclaredWithTypename())
2507 PlaceholderStr =
"typename";
2509 PlaceholderStr =
"class";
2511 if (TTP->getIdentifier()) {
2512 PlaceholderStr +=
' ';
2516 HasDefaultArg = TTP->hasDefaultArgument();
2518 = dyn_cast<NonTypeTemplateParmDecl>(*
P)) {
2519 if (NTTP->getIdentifier())
2520 PlaceholderStr = NTTP->getIdentifier()->getName();
2521 NTTP->getType().getAsStringInternal(PlaceholderStr, Policy);
2522 HasDefaultArg = NTTP->hasDefaultArgument();
2524 assert(isa<TemplateTemplateParmDecl>(*
P));
2529 PlaceholderStr =
"template<...> class";
2531 PlaceholderStr +=
' ';
2538 if (HasDefaultArg && !InDefaultArg) {
2543 if (!FirstParameter)
2546 P - Params->begin(),
true);
2551 InDefaultArg =
false;
2554 FirstParameter =
false;
2569 bool QualifierIsInformative,
2575 std::string PrintedNNS;
2577 llvm::raw_string_ostream OS(PrintedNNS);
2578 Qualifier->
print(OS, Policy);
2580 if (QualifierIsInformative)
2613 std::string QualsStr;
2615 QualsStr +=
" const";
2617 QualsStr +=
" volatile";
2619 QualsStr +=
" restrict";
2633 const char *OperatorName =
nullptr;
2636 case OO_Conditional:
2638 OperatorName =
"operator";
2641 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2642 case OO_##Name: OperatorName = "operator" Spelling; break;
2643 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2644 #include "clang/Basic/OperatorKinds.def"
2646 case OO_New: OperatorName =
"operator new";
break;
2647 case OO_Delete: OperatorName =
"operator delete";
break;
2648 case OO_Array_New: OperatorName =
"operator new[]";
break;
2649 case OO_Array_Delete: OperatorName =
"operator delete[]";
break;
2650 case OO_Call: OperatorName =
"operator()";
break;
2651 case OO_Subscript: OperatorName =
"operator[]";
break;
2676 Record = cast<CXXRecordDecl>(RecordTy->getDecl());
2679 Record = InjectedTy->getDecl();
2702 bool IncludeBriefComments) {
2703 return CreateCodeCompletionString(S.
Context, S.
PP, CCContext, Allocator,
2704 CCTUInfo, IncludeBriefComments);
2719 bool IncludeBriefComments) {
2723 if (
Kind == RK_Pattern) {
2724 Pattern->Priority = Priority;
2725 Pattern->Availability = Availability;
2736 if (M->isPropertyAccessor())
2738 if (PDecl->getGetterName() == M->getSelector() &&
2739 PDecl->getIdentifier() != M->getIdentifier()) {
2756 if (
Kind == RK_Keyword) {
2761 if (
Kind == RK_Macro) {
2804 assert(
Kind == RK_Declaration &&
"Missed a result kind?");
2808 if (IncludeBriefComments) {
2813 else if (
const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND))
2814 if (OMD->isPropertyAccessor())
2820 if (StartsNestedNameSpecifier) {
2832 if (
const FunctionDecl *Function = dyn_cast<FunctionDecl>(ND)) {
2851 llvm::SmallBitVector Deduced;
2853 unsigned LastDeducibleArgument;
2854 for (LastDeducibleArgument = Deduced.size(); LastDeducibleArgument > 0;
2855 --LastDeducibleArgument) {
2856 if (!Deduced[LastDeducibleArgument - 1]) {
2860 bool HasDefaultArg =
false;
2861 NamedDecl *Param = FunTmpl->getTemplateParameters()->getParam(
2862 LastDeducibleArgument - 1);
2864 HasDefaultArg = TTP->hasDefaultArgument();
2866 = dyn_cast<NonTypeTemplateParmDecl>(Param))
2867 HasDefaultArg = NTTP->hasDefaultArgument();
2869 assert(isa<TemplateTemplateParmDecl>(Param));
2871 = cast<TemplateTemplateParmDecl>(Param)->hasDefaultArgument();
2879 if (LastDeducibleArgument) {
2885 LastDeducibleArgument);
2897 if (
const TemplateDecl *Template = dyn_cast<TemplateDecl>(ND)) {
2908 if (
const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(ND)) {
2909 Selector Sel = Method->getSelector();
2918 if (StartParameter == 0)
2925 if (Method->param_size() == 1)
2930 PEnd = Method->param_end();
2931 P != PEnd; (void)++
P, ++Idx) {
2933 std::string Keyword;
2934 if (Idx > StartParameter)
2937 Keyword += II->getName();
2939 if (Idx < StartParameter || AllParametersAreInformative)
2946 if (Idx < StartParameter)
2950 QualType ParamType = (*P)->getType();
2967 if (DeclaringEntity || AllParametersAreInformative)
2968 Arg += II->getName();
2971 if (Method->isVariadic() && (
P + 1) == PEnd)
2974 if (DeclaringEntity)
2976 else if (AllParametersAreInformative)
2982 if (Method->isVariadic()) {
2983 if (Method->param_size() == 0) {
2984 if (DeclaringEntity)
2986 else if (AllParametersAreInformative)
3014 unsigned CurrentArg,
3016 bool InOptional =
false) {
3017 bool FirstParameter =
true;
3018 unsigned NumParams = Function ? Function->
getNumParams()
3021 for (
unsigned P = Start;
P != NumParams; ++
P) {
3027 if (!FirstParameter)
3031 CurrentArg,
P,
true);
3037 FirstParameter =
false;
3044 std::string Placeholder;
3054 if (
P == CurrentArg)
3064 if (!FirstParameter)
3067 if (CurrentArg < NumParams)
3068 Opt.AddPlaceholderChunk(
"...");
3070 Opt.AddCurrentParameterChunk(
"...");
3078 unsigned CurrentArg,
Sema &
S,
3081 bool IncludeBriefComments)
const {
3089 if (!FDecl && !Proto) {
3102 if (IncludeBriefComments && CurrentArg < FDecl->getNumParams())
3120 return Result.TakeString();
3125 bool PreferredTypeIsPointer) {
3129 if (MacroName.equals(
"nil") || MacroName.equals(
"NULL") ||
3130 MacroName.equals(
"Nil")) {
3132 if (PreferredTypeIsPointer)
3136 else if (MacroName.equals(
"YES") || MacroName.equals(
"NO") ||
3137 MacroName.equals(
"true") || MacroName.equals(
"false"))
3140 else if (MacroName.equals(
"bool"))
3155 case Decl::Function:
3163 case Decl::ObjCMethod:
3185 case Decl::ClassTemplatePartialSpecialization:
3193 case Decl::UnresolvedUsingValue:
3194 case Decl::UnresolvedUsingTypename:
3197 case Decl::ObjCPropertyImpl:
3198 switch (cast<ObjCPropertyImplDecl>(D)->getPropertyImplementation()) {
3212 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
3213 switch (TD->getTagKind()) {
3227 bool IncludeUndefined,
3228 bool TargetTypeIsPointer =
false) {
3231 Results.EnterNewScope();
3237 if (IncludeUndefined || MD) {
3239 if (MI->isUsedForHeaderGuard())
3242 Results.AddResult(Result(M->first,
3245 TargetTypeIsPointer)));
3249 Results.ExitScope();
3254 ResultBuilder &Results) {
3257 Results.EnterNewScope();
3259 Results.AddResult(Result(
"__PRETTY_FUNCTION__",
CCP_Constant));
3260 Results.AddResult(Result(
"__FUNCTION__",
CCP_Constant));
3261 if (LangOpts.C99 || LangOpts.CPlusPlus11)
3263 Results.ExitScope();
3270 unsigned NumResults) {
3328 llvm_unreachable(
"Invalid ParserCompletionContext!");
3340 ResultBuilder &Results) {
3343 while (isa<BlockDecl>(CurContext))
3354 if (!
P->getDeclName())
3362 Results.getCodeCompletionTUInfo());
3371 Overridden->getDeclContext());
3374 llvm::raw_string_ostream OS(Str);
3375 NNS->
print(OS, Policy);
3376 Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
3378 }
else if (!InContext->
Equals(Overridden->getDeclContext()))
3381 Builder.AddTypedTextChunk(Results.getAllocator().CopyString(
3382 Overridden->getNameAsString()));
3384 bool FirstParam =
true;
3392 Results.getAllocator().CopyString(
P->getIdentifier()->getName()));
3400 Results.Ignore(Overridden);
3407 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3408 CodeCompleter->getCodeCompletionTUInfo(),
3410 Results.EnterNewScope();
3418 PP.getHeaderSearchInfo().collectAllModules(Modules);
3419 for (
unsigned I = 0, N = Modules.size(); I != N; ++
I) {
3421 Builder.getAllocator().CopyString(Modules[I]->
Name));
3422 Results.AddResult(Result(
Builder.TakeString(),
3425 Modules[
I]->isAvailable()
3429 }
else if (getLangOpts().Modules) {
3431 Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path,
3438 Sub != SubEnd; ++Sub) {
3441 Builder.getAllocator().CopyString((*Sub)->Name));
3442 Results.AddResult(Result(
Builder.TakeString(),
3445 (*Sub)->isAvailable()
3451 Results.ExitScope();
3453 Results.data(),Results.size());
3458 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3459 CodeCompleter->getCodeCompletionTUInfo(),
3461 Results.EnterNewScope();
3466 switch (CompletionContext) {
3469 case PCC_ObjCInterface:
3470 case PCC_ObjCImplementation:
3471 case PCC_ObjCInstanceVariableList:
3473 case PCC_MemberTemplate:
3475 case PCC_LocalDeclarationSpecifiers:
3476 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
3480 case PCC_ParenthesizedExpression:
3481 case PCC_Expression:
3485 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3487 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3493 case PCC_RecoveryInFunction:
3500 if (
CXXMethodDecl *CurMethod = dyn_cast<CXXMethodDecl>(CurContext))
3501 if (CurMethod->isInstance())
3502 Results.setObjectTypeQualifiers(
3505 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3507 CodeCompleter->includeGlobals());
3510 Results.ExitScope();
3512 switch (CompletionContext) {
3513 case PCC_ParenthesizedExpression:
3514 case PCC_Expression:
3516 case PCC_RecoveryInFunction:
3523 case PCC_ObjCInterface:
3524 case PCC_ObjCImplementation:
3525 case PCC_ObjCInstanceVariableList:
3527 case PCC_MemberTemplate:
3531 case PCC_LocalDeclarationSpecifiers:
3535 if (CodeCompleter->includeMacros())
3539 Results.data(),Results.size());
3545 bool AtArgumentExpression,
3547 ResultBuilder &Results);
3550 bool AllowNonIdentifiers,
3551 bool AllowNestedNameSpecifiers) {
3553 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3554 CodeCompleter->getCodeCompletionTUInfo(),
3555 AllowNestedNameSpecifiers
3558 Results.EnterNewScope();
3561 Results.AddResult(Result(
"const"));
3562 Results.AddResult(Result(
"volatile"));
3563 if (getLangOpts().
C99)
3564 Results.AddResult(Result(
"restrict"));
3570 Results.AddResult(
"final");
3572 if (AllowNonIdentifiers) {
3573 Results.AddResult(Result(
"operator"));
3577 if (AllowNestedNameSpecifiers) {
3578 Results.allowNestedNameSpecifiers();
3579 Results.setFilter(&ResultBuilder::IsImpossibleToSatisfy);
3580 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3582 CodeCompleter->includeGlobals());
3583 Results.setFilter(
nullptr);
3586 Results.ExitScope();
3592 if (AllowNonIdentifiers && !AllowNestedNameSpecifiers &&
3612 Results.getCompletionContext(),
3613 Results.data(), Results.size());
3618 : PreferredType(PreferredType), IntegralConstantExpression(
false),
3619 ObjCCollection(
false) { }
3631 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3632 CodeCompleter->getCodeCompletionTUInfo(),
3635 Results.setFilter(&ResultBuilder::IsObjCCollection);
3637 Results.setFilter(&ResultBuilder::IsIntegralConstantValue);
3639 Results.setFilter(&ResultBuilder::IsOrdinaryName);
3641 Results.setFilter(&ResultBuilder::IsOrdinaryNonTypeName);
3647 for (
unsigned I = 0, N = Data.
IgnoreDecls.size(); I != N; ++
I)
3650 CodeCompletionDeclConsumer Consumer(Results, CurContext);
3652 CodeCompleter->includeGlobals());
3654 Results.EnterNewScope();
3656 Results.ExitScope();
3658 bool PreferredTypeIsPointer =
false;
3669 if (CodeCompleter->includeMacros())
3674 Results.data(),Results.size());
3679 CodeCompleteOrdinaryName(S, PCC_RecoveryInFunction);
3680 else if (getLangOpts().ObjC1)
3681 CodeCompleteObjCInstanceMessage(S, E.
get(),
None,
false);
3691 if (Interface->hasDefinition())
3692 return Interface->getDefinition();
3698 if (Protocol->hasDefinition())
3699 return Protocol->getDefinition();
3723 for (
unsigned I = 0, N = BlockLoc.
getNumParams(); I != N; ++
I) {
3728 std::string PlaceholderStr =
3731 if (I == N - 1 && BlockProtoLoc &&
3733 PlaceholderStr +=
", ...";
3746 bool AllowCategories,
bool AllowNullaryMethods,
DeclContext *CurContext,
3748 bool IsBaseExprStatement =
false,
bool IsClassProperty =
false) {
3756 if (!AddedProperties.insert(
P->getIdentifier()).second)
3761 if (!
P->getType().getTypePtr()->isBlockPointerType() ||
3762 !IsBaseExprStatement) {
3763 Results.MaybeAddResult(Result(
P, Results.getBasePriority(
P),
nullptr),
3775 Results.MaybeAddResult(Result(
P, Results.getBasePriority(
P),
nullptr),
3783 Results.getCodeCompletionTUInfo());
3786 BlockLoc, BlockProtoLoc);
3787 Results.MaybeAddResult(
3788 Result(
Builder.TakeString(),
P, Results.getBasePriority(
P)),
3793 if (!
P->isReadOnly()) {
3795 Results.getCodeCompletionTUInfo());
3800 Results.getAllocator().CopyString(
P->getName()));
3805 BlockProtoLoc,
true);
3808 Builder.getAllocator().CopyString(PlaceholderStr));
3815 Results.MaybeAddResult(
3817 Results.getBasePriority(
P) +
3825 if (IsClassProperty) {
3834 if (AllowNullaryMethods) {
3842 if (!AddedProperties.insert(Name).second)
3845 Results.getCodeCompletionTUInfo());
3848 Results.getAllocator().CopyString(Name->
getName()));
3849 Results.MaybeAddResult(
3850 Result(
Builder.TakeString(), M,
3855 if (IsClassProperty) {
3856 for (
const auto *M : Container->
methods()) {
3860 if (!M->getSelector().isUnarySelector() ||
3861 M->getReturnType()->isVoidType() || M->isInstanceMethod())
3866 for (
auto *M : Container->
methods()) {
3867 if (M->getSelector().isUnarySelector())
3875 for (
auto *
P : Protocol->protocols())
3877 CurContext, AddedProperties, Results,
3878 IsBaseExprStatement, IsClassProperty);
3880 if (AllowCategories) {
3882 for (
auto *Cat : IFace->known_categories())
3884 CurContext, AddedProperties, Results,
3885 IsBaseExprStatement, IsClassProperty);
3889 for (
auto *I : IFace->all_referenced_protocols())
3891 CurContext, AddedProperties, Results,
3892 IsBaseExprStatement, IsClassProperty);
3895 if (IFace->getSuperClass())
3897 AllowNullaryMethods, CurContext, AddedProperties,
3898 Results, IsBaseExprStatement, IsClassProperty);
3900 = dyn_cast<ObjCCategoryDecl>(Container)) {
3904 CurContext, AddedProperties, Results,
3905 IsBaseExprStatement, IsClassProperty);
3910 ResultBuilder &Results,
Scope *
S,
3918 Results.allowNestedNameSpecifiers();
3919 CodeCompletionDeclConsumer Consumer(Results, SemaRef.
CurContext);
3925 if (!Results.empty()) {
3931 for (
Scope *DepScope = S; DepScope; DepScope = DepScope->
getParent())
3946 bool IsBaseExprStatement) {
3947 if (!Base || !CodeCompleter)
3950 ExprResult ConvertedBase = PerformMemberExprBaseConversion(Base, IsArrow);
3953 Base = ConvertedBase.
get();
3982 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
3983 CodeCompleter->getCodeCompletionTUInfo(),
3985 &ResultBuilder::IsMember);
3986 Results.EnterNewScope();
3992 if (
const auto *TD =
3998 if (
auto *RD = ICNT->getDecl())
4007 assert(ObjCPtr &&
"Non-NULL pointer guaranteed above!");
4010 AddedProperties, Results, IsBaseExprStatement);
4016 CurContext, AddedProperties, Results,
4017 IsBaseExprStatement);
4024 Class = ObjCPtr->getInterfaceDecl();
4030 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4031 Results.setFilter(&ResultBuilder::IsObjCIvar);
4033 CodeCompleter->includeGlobals());
4039 Results.ExitScope();
4043 Results.getCompletionContext(),
4044 Results.data(),Results.size());
4050 bool IsBaseExprStatement) {
4057 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4058 CodeCompleter->getCodeCompletionTUInfo(), CCContext,
4059 &ResultBuilder::IsMember);
4060 Results.EnterNewScope();
4063 true, CurContext, AddedProperties,
4064 Results, IsBaseExprStatement,
4066 Results.ExitScope();
4068 Results.data(), Results.size());
4075 ResultBuilder::LookupFilter Filter =
nullptr;
4080 Filter = &ResultBuilder::IsEnum;
4085 Filter = &ResultBuilder::IsUnion;
4092 Filter = &ResultBuilder::IsClassOrStruct;
4097 llvm_unreachable(
"Unknown type specifier kind in CodeCompleteTag");
4100 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4101 CodeCompleter->getCodeCompletionTUInfo(),
ContextKind);
4102 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4105 Results.setFilter(Filter);
4107 CodeCompleter->includeGlobals());
4109 if (CodeCompleter->includeGlobals()) {
4111 Results.setFilter(&ResultBuilder::IsNestedNameSpecifier);
4116 Results.data(),Results.size());
4122 Results.AddResult(
"const");
4124 Results.AddResult(
"volatile");
4126 Results.AddResult(
"restrict");
4128 Results.AddResult(
"_Atomic");
4130 Results.AddResult(
"__unaligned");
4134 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4135 CodeCompleter->getCodeCompletionTUInfo(),
4137 Results.EnterNewScope();
4139 Results.ExitScope();
4141 Results.getCompletionContext(),
4142 Results.data(), Results.size());
4147 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4148 CodeCompleter->getCodeCompletionTUInfo(),
4150 Results.EnterNewScope();
4152 if (LangOpts.CPlusPlus11) {
4153 Results.AddResult(
"noexcept");
4157 Results.AddResult(
"final");
4159 Results.AddResult(
"override");
4162 Results.ExitScope();
4164 Results.data(), Results.size());
4168 CodeCompleteExpression(S,
QualType(getASTContext().getSizeType()));
4172 if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
4175 SwitchStmt *Switch = getCurFunction()->SwitchStack.back();
4180 CodeCompleteExpression(S, Data);
4194 llvm::SmallPtrSet<EnumConstantDecl *, 8> EnumeratorsSeen;
4203 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CaseVal))
4205 = dyn_cast<EnumConstantDecl>(DRE->getDecl())) {
4212 EnumeratorsSeen.insert(Enumerator);
4225 Qualifier = DRE->getQualifier();
4229 if (getLangOpts().
CPlusPlus && !Qualifier && EnumeratorsSeen.empty()) {
4237 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4238 CodeCompleter->getCodeCompletionTUInfo(),
4240 Results.EnterNewScope();
4242 if (EnumeratorsSeen.count(
E))
4246 Results.AddResult(R, CurContext,
nullptr,
false);
4248 Results.ExitScope();
4253 if (CodeCompleter->includeMacros()) {
4260 Results.data(),Results.size());
4264 if (Args.size() && !Args.data())
4267 for (
unsigned I = 0; I != Args.size(); ++
I)
4280 if (!CandidateSet.
empty()) {
4283 CandidateSet.
begin(), CandidateSet.
end(),
4289 for (
auto &Candidate : CandidateSet)
4290 if (Candidate.Viable)
4298 ArrayRef<ResultCandidate> Candidates,
4305 for (
auto &Candidate : Candidates) {
4306 if (
auto FType = Candidate.getFunctionType())
4307 if (
auto Proto = dyn_cast<FunctionProtoType>(FType))
4308 if (N < Proto->getNumParams()) {
4310 ParamType = Proto->getParamType(N);
4313 Proto->getParamType(N).getNonReferenceType()))
4324 unsigned CurrentArg,
4325 bool CompleteExpressionWithCurrentArg =
true) {
4327 if (CompleteExpressionWithCurrentArg)
4328 ParamType =
getParamType(SemaRef, Candidates, CurrentArg);
4335 if (!Candidates.empty())
4355 CodeCompleteOrdinaryName(S, PCC_Expression);
4366 if (
auto ULE = dyn_cast<UnresolvedLookupExpr>(NakedFn))
4367 AddOverloadedCallCandidates(ULE, Args, CandidateSet,
4369 else if (
auto UME = dyn_cast<UnresolvedMemberExpr>(NakedFn)) {
4371 if (UME->hasExplicitTemplateArgs()) {
4372 UME->copyTemplateArgumentsInto(TemplateArgsBuffer);
4373 TemplateArgs = &TemplateArgsBuffer;
4378 1, UME->isImplicitAccess() ?
nullptr : UME->getBase());
4379 ArgExprs.append(Args.begin(), Args.end());
4381 Decls.
append(UME->decls_begin(), UME->decls_end());
4382 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
4387 if (
auto MCE = dyn_cast<MemberExpr>(NakedFn))
4389 else if (
auto DRE = dyn_cast<DeclRefExpr>(NakedFn))
4390 FD = dyn_cast<FunctionDecl>(DRE->getDecl());
4392 if (!getLangOpts().CPlusPlus ||
4405 if (isCompleteType(Loc, NakedFn->
getType())) {
4408 LookupResult R(*
this, OpName, Loc, LookupOrdinaryName);
4409 LookupQualifiedName(R, DC);
4412 ArgExprs.append(Args.begin(), Args.end());
4426 if (!TooManyArguments(FP->getNumParams(), Args.size(),
4438 !CandidateSet.
empty());
4447 if (!isCompleteType(Loc, Type))
4452 CodeCompleteExpression(S, Type);
4461 for (
auto C : LookupConstructors(RD)) {
4462 if (
auto FD = dyn_cast<FunctionDecl>(C)) {
4467 }
else if (
auto FTD = dyn_cast<FunctionTemplateDecl>(C)) {
4468 AddTemplateOverloadCandidate(FTD,
4483 ValueDecl *VD = dyn_cast_or_null<ValueDecl>(D);
4485 CodeCompleteOrdinaryName(S, PCC_Expression);
4489 CodeCompleteExpression(S, VD->
getType());
4494 if (isa<BlockDecl>(CurContext)) {
4496 ResultType = BSI->ReturnType;
4497 }
else if (
FunctionDecl *Function = dyn_cast<FunctionDecl>(CurContext))
4498 ResultType = Function->getReturnType();
4499 else if (
ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(CurContext))
4500 ResultType = Method->getReturnType();
4503 CodeCompleteOrdinaryName(S, PCC_Expression);
4505 CodeCompleteExpression(S, ResultType);
4509 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4510 CodeCompleter->getCodeCompletionTUInfo(),
4512 Results.setFilter(&ResultBuilder::IsOrdinaryName);
4513 Results.EnterNewScope();
4515 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4517 CodeCompleter->includeGlobals());
4523 Results.getCodeCompletionTUInfo());
4524 Builder.AddTypedTextChunk(
"else");
4525 if (Results.includeCodePatterns()) {
4529 Builder.AddPlaceholderChunk(
"statements");
4533 Results.AddResult(
Builder.TakeString());
4536 Builder.AddTypedTextChunk(
"else");
4542 Builder.AddPlaceholderChunk(
"condition");
4544 Builder.AddPlaceholderChunk(
"expression");
4546 if (Results.includeCodePatterns()) {
4550 Builder.AddPlaceholderChunk(
"statements");
4554 Results.AddResult(
Builder.TakeString());
4556 Results.ExitScope();
4561 if (CodeCompleter->includeMacros())
4565 Results.data(),Results.size());
4570 CodeCompleteExpression(S, static_cast<Expr *>(LHS)->getType());
4572 CodeCompleteOrdinaryName(S, PCC_Expression);
4576 bool EnteringContext) {
4588 if (!isDependentScopeSpecifier(SS) && RequireCompleteDeclContext(SS, Ctx))
4591 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4592 CodeCompleter->getCodeCompletionTUInfo(),
4594 Results.EnterNewScope();
4600 Results.AddResult(
"template");
4607 if (!EnteringContext)
4609 Results.ExitScope();
4611 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4617 Results.getCompletionContext(),
4618 Results.data(),Results.size());
4625 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4626 CodeCompleter->getCodeCompletionTUInfo(),
4628 &ResultBuilder::IsNestedNameSpecifier);
4629 Results.EnterNewScope();
4637 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4639 CodeCompleter->includeGlobals());
4640 Results.ExitScope();
4644 Results.data(),Results.size());
4653 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4654 CodeCompleter->getCodeCompletionTUInfo(),
4656 &ResultBuilder::IsNamespaceOrAlias);
4657 Results.EnterNewScope();
4658 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4660 CodeCompleter->includeGlobals());
4661 Results.ExitScope();
4664 Results.data(),Results.size());
4675 bool SuppressedGlobalResults
4676 = Ctx && !CodeCompleter->includeGlobals() && isa<TranslationUnitDecl>(Ctx);
4678 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4679 CodeCompleter->getCodeCompletionTUInfo(),
4680 SuppressedGlobalResults
4683 &ResultBuilder::IsNamespace);
4685 if (Ctx && Ctx->
isFileContext() && !SuppressedGlobalResults) {
4690 std::map<NamespaceDecl *, NamespaceDecl *> OrigToLatest;
4694 OrigToLatest[NS->getOriginalNamespace()] = *NS;
4698 Results.EnterNewScope();
4699 for (std::map<NamespaceDecl *, NamespaceDecl *>::iterator
4700 NS = OrigToLatest.begin(),
4701 NSEnd = OrigToLatest.end();
4704 NS->second, Results.getBasePriority(NS->second),
4706 CurContext,
nullptr,
false);
4707 Results.ExitScope();
4711 Results.getCompletionContext(),
4712 Results.data(),Results.size());
4720 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4721 CodeCompleter->getCodeCompletionTUInfo(),
4723 &ResultBuilder::IsNamespaceOrAlias);
4724 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4726 CodeCompleter->includeGlobals());
4728 Results.getCompletionContext(),
4729 Results.data(),Results.size());
4737 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4738 CodeCompleter->getCodeCompletionTUInfo(),
4740 &ResultBuilder::IsType);
4741 Results.EnterNewScope();
4744 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
4745 if (std::strcmp(Spelling, "?")) \
4746 Results.AddResult(Result(Spelling));
4747 #include "clang/Basic/OperatorKinds.def"
4750 Results.allowNestedNameSpecifiers();
4751 CodeCompletionDeclConsumer Consumer(Results, CurContext);
4753 CodeCompleter->includeGlobals());
4757 Results.ExitScope();
4761 Results.data(),Results.size());
4770 AdjustDeclIfTemplate(ConstructorD);
4776 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4777 CodeCompleter->getCodeCompletionTUInfo(),
4779 Results.EnterNewScope();
4782 llvm::SmallPtrSet<FieldDecl *, 4> InitializedFields;
4783 llvm::SmallPtrSet<CanQualType, 4> InitializedBases;
4784 for (
unsigned I = 0,
E = Initializers.size(); I !=
E; ++
I) {
4785 if (Initializers[I]->isBaseInitializer())
4786 InitializedBases.insert(
4789 InitializedFields.insert(cast<FieldDecl>(
4790 Initializers[I]->getAnyMember()));
4795 Results.getCodeCompletionTUInfo());
4797 bool SawLastInitializer = Initializers.empty();
4799 for (
const auto &
Base : ClassDecl->
bases()) {
4803 = !Initializers.empty() &&
4804 Initializers.back()->isBaseInitializer() &&
4806 QualType(Initializers.back()->getBaseClass(), 0));
4811 Results.getAllocator().CopyString(
4812 Base.getType().getAsString(Policy)));
4814 Builder.AddPlaceholderChunk(
"args");
4819 SawLastInitializer =
false;
4823 for (
const auto &
Base : ClassDecl->
vbases()) {
4827 = !Initializers.empty() &&
4828 Initializers.back()->isBaseInitializer() &&
4830 QualType(Initializers.back()->getBaseClass(), 0));
4835 Builder.getAllocator().CopyString(
4836 Base.getType().getAsString(Policy)));
4838 Builder.AddPlaceholderChunk(
"args");
4843 SawLastInitializer =
false;
4847 for (
auto *Field : ClassDecl->
fields()) {
4848 if (!InitializedFields.insert(cast<FieldDecl>(Field->getCanonicalDecl()))
4851 = !Initializers.empty() &&
4852 Initializers.back()->isAnyMemberInitializer() &&
4853 Initializers.back()->getAnyMember() == Field;
4857 if (!Field->getDeclName())
4861 Field->getIdentifier()->getName()));
4863 Builder.AddPlaceholderChunk(
"args");
4871 SawLastInitializer =
false;
4873 Results.ExitScope();
4876 Results.data(), Results.size());
4889 bool AfterAmpersand) {
4890 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
4891 CodeCompleter->getCodeCompletionTUInfo(),
4893 Results.EnterNewScope();
4896 llvm::SmallPtrSet<IdentifierInfo *, 4> Known;
4897 bool IncludedThis =
false;
4898 for (
const auto &C : Intro.
Captures) {
4900 IncludedThis =
true;
4909 for (
const auto *D : S->
decls()) {
4910 const auto *Var = dyn_cast<
VarDecl>(D);
4918 CurContext,
nullptr,
false);
4926 Results.ExitScope();
4929 Results.data(), Results.size());
4934 #define OBJC_AT_KEYWORD_NAME(NeedAt,Keyword) ((NeedAt)? "@" Keyword : Keyword)
4937 ResultBuilder &Results,
4944 Results.getCodeCompletionTUInfo());
4945 if (LangOpts.ObjC2) {
4949 Builder.AddPlaceholderChunk(
"property");
4950 Results.AddResult(Result(
Builder.TakeString()));
4955 Builder.AddPlaceholderChunk(
"property");
4956 Results.AddResult(Result(
Builder.TakeString()));
4961 ResultBuilder &Results,
4968 if (LangOpts.ObjC2) {
4983 Results.getCodeCompletionTUInfo());
4988 Builder.AddPlaceholderChunk(
"name");
4989 Results.AddResult(Result(
Builder.TakeString()));
4991 if (Results.includeCodePatterns()) {
4997 Builder.AddPlaceholderChunk(
"class");
4998 Results.AddResult(Result(
Builder.TakeString()));
5003 Builder.AddPlaceholderChunk(
"protocol");
5004 Results.AddResult(Result(
Builder.TakeString()));
5009 Builder.AddPlaceholderChunk(
"class");
5010 Results.AddResult(Result(
Builder.TakeString()));
5016 Builder.AddPlaceholderChunk(
"alias");
5018 Builder.AddPlaceholderChunk(
"class");
5019 Results.AddResult(Result(
Builder.TakeString()));
5021 if (Results.getSema().getLangOpts().Modules) {
5025 Builder.AddPlaceholderChunk(
"module");
5026 Results.AddResult(Result(
Builder.TakeString()));
5031 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5032 CodeCompleter->getCodeCompletionTUInfo(),
5034 Results.EnterNewScope();
5035 if (isa<ObjCImplDecl>(CurContext))
5041 Results.ExitScope();
5044 Results.data(),Results.size());
5050 Results.getCodeCompletionTUInfo());
5053 const char *EncodeType =
"char[]";
5054 if (Results.getSema().getLangOpts().CPlusPlus ||
5055 Results.getSema().getLangOpts().ConstStrings)
5056 EncodeType =
"const char[]";
5057 Builder.AddResultTypeChunk(EncodeType);
5060 Builder.AddPlaceholderChunk(
"type-name");
5062 Results.AddResult(Result(
Builder.TakeString()));
5065 Builder.AddResultTypeChunk(
"Protocol *");
5068 Builder.AddPlaceholderChunk(
"protocol-name");
5070 Results.AddResult(Result(
Builder.TakeString()));
5073 Builder.AddResultTypeChunk(
"SEL");
5076 Builder.AddPlaceholderChunk(
"selector");
5078 Results.AddResult(Result(
Builder.TakeString()));
5081 Builder.AddResultTypeChunk(
"NSString *");
5083 Builder.AddPlaceholderChunk(
"string");
5085 Results.AddResult(Result(
Builder.TakeString()));
5088 Builder.AddResultTypeChunk(
"NSArray *");
5090 Builder.AddPlaceholderChunk(
"objects, ...");
5092 Results.AddResult(Result(
Builder.TakeString()));
5095 Builder.AddResultTypeChunk(
"NSDictionary *");
5097 Builder.AddPlaceholderChunk(
"key");
5100 Builder.AddPlaceholderChunk(
"object, ...");
5102 Results.AddResult(Result(
Builder.TakeString()));
5105 Builder.AddResultTypeChunk(
"id");
5107 Builder.AddPlaceholderChunk(
"expression");
5109 Results.AddResult(Result(
Builder.TakeString()));
5115 Results.getCodeCompletionTUInfo());
5117 if (Results.includeCodePatterns()) {
5122 Builder.AddPlaceholderChunk(
"statements");
5124 Builder.AddTextChunk(
"@catch");
5126 Builder.AddPlaceholderChunk(
"parameter");
5129 Builder.AddPlaceholderChunk(
"statements");
5131 Builder.AddTextChunk(
"@finally");
5133 Builder.AddPlaceholderChunk(
"statements");
5135 Results.AddResult(Result(
Builder.TakeString()));
5141 Builder.AddPlaceholderChunk(
"expression");
5142 Results.AddResult(Result(
Builder.TakeString()));
5144 if (Results.includeCodePatterns()) {
5149 Builder.AddPlaceholderChunk(
"expression");
5152 Builder.AddPlaceholderChunk(
"statements");
5154 Results.AddResult(Result(
Builder.TakeString()));
5159 ResultBuilder &Results,
5170 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5171 CodeCompleter->getCodeCompletionTUInfo(),
5173 Results.EnterNewScope();
5175 Results.ExitScope();
5178 Results.data(),Results.size());
5182 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5183 CodeCompleter->getCodeCompletionTUInfo(),
5185 Results.EnterNewScope();
5188 Results.ExitScope();
5191 Results.data(),Results.size());
5195 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5196 CodeCompleter->getCodeCompletionTUInfo(),
5198 Results.EnterNewScope();
5200 Results.ExitScope();
5203 Results.data(),Results.size());
5210 if (Attributes & NewFlag)
5213 Attributes |= NewFlag;
5227 if (AssignCopyRetMask &&
5245 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5246 CodeCompleter->getCodeCompletionTUInfo(),
5248 Results.EnterNewScope();
5276 Results.getCodeCompletionTUInfo());
5278 Setter.AddTextChunk(
"=");
5279 Setter.AddPlaceholderChunk(
"method");
5284 Results.getCodeCompletionTUInfo());
5286 Getter.AddTextChunk(
"=");
5287 Getter.AddPlaceholderChunk(
"method");
5296 Results.ExitScope();
5299 Results.data(),Results.size());
5312 ArrayRef<IdentifierInfo *> SelIdents,
5313 bool AllowSameLength =
true) {
5314 unsigned NumSelIdents = SelIdents.size();
5324 if (!AllowSameLength && NumSelIdents && NumSelIdents == Sel.
getNumArgs())
5327 for (
unsigned I = 0; I != NumSelIdents; ++
I)
5336 ArrayRef<IdentifierInfo *> SelIdents,
5337 bool AllowSameLength =
true) {
5345 typedef llvm::SmallPtrSet<Selector, 16> VisitedSelectorSet;
5370 ArrayRef<IdentifierInfo *> SelIdents,
5372 VisitedSelectorSet &Selectors,
bool AllowSameLength,
5373 ResultBuilder &Results,
bool InOriginalClass =
true,
5374 bool IsRootClass =
false) {
5378 IsRootClass = IsRootClass || (IFace && !IFace->
getSuperClass());
5379 for (
auto *M : Container->
methods()) {
5382 if (M->isInstanceMethod() == WantInstanceMethods ||
5383 (IsRootClass && !WantInstanceMethods)) {
5389 if (!Selectors.insert(M->getSelector()).second)
5392 Result R = Result(M, Results.getBasePriority(M),
nullptr);
5393 R.StartParameter = SelIdents.size();
5394 R.AllParametersAreInformative = (WantKind !=
MK_Any);
5395 if (!InOriginalClass)
5397 Results.MaybeAddResult(R, CurContext);
5403 if (Protocol->hasDefinition()) {
5405 = Protocol->getReferencedProtocols();
5407 E = Protocols.
end();
5409 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5410 Selectors, AllowSameLength, Results,
false, IsRootClass);
5419 AddObjCMethods(I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5420 Selectors, AllowSameLength, Results,
false, IsRootClass);
5424 AddObjCMethods(CatDecl, WantInstanceMethods, WantKind, SelIdents,
5425 CurContext, Selectors, AllowSameLength, Results,
5426 InOriginalClass, IsRootClass);
5430 = CatDecl->getReferencedProtocols();
5432 E = Protocols.
end();
5434 AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, CurContext,
5435 Selectors, AllowSameLength, Results,
false, IsRootClass);
5439 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5440 Selectors, AllowSameLength, Results, InOriginalClass,
5448 SelIdents, CurContext, Selectors, AllowSameLength, Results,
5453 AddObjCMethods(Impl, WantInstanceMethods, WantKind, SelIdents, CurContext,
5454 Selectors, AllowSameLength, Results, InOriginalClass,
5464 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5465 Class =
Category->getClassInterface();
5472 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5473 CodeCompleter->getCodeCompletionTUInfo(),
5475 Results.EnterNewScope();
5477 VisitedSelectorSet Selectors;
5480 Results.ExitScope();
5483 Results.data(),Results.size());
5489 = dyn_cast_or_null<ObjCInterfaceDecl>(CurContext);
5492 = dyn_cast_or_null<ObjCCategoryDecl>(CurContext))
5493 Class =
Category->getClassInterface();
5500 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5501 CodeCompleter->getCodeCompletionTUInfo(),
5503 Results.EnterNewScope();
5505 VisitedSelectorSet Selectors;
5507 Selectors,
true, Results);
5509 Results.ExitScope();
5512 Results.data(),Results.size());
5517 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5518 CodeCompleter->getCodeCompletionTUInfo(),
5520 Results.EnterNewScope();
5523 bool AddedInOut =
false;
5526 Results.AddResult(
"in");
5527 Results.AddResult(
"inout");
5532 Results.AddResult(
"out");
5534 Results.AddResult(
"inout");
5539 Results.AddResult(
"bycopy");
5540 Results.AddResult(
"byref");
5541 Results.AddResult(
"oneway");
5544 Results.AddResult(
"nonnull");
5545 Results.AddResult(
"nullable");
5546 Results.AddResult(
"null_unspecified");
5554 PP.isMacroDefined(
"IBAction")) {
5556 Results.getCodeCompletionTUInfo(),
5558 Builder.AddTypedTextChunk(
"IBAction");
5560 Builder.AddPlaceholderChunk(
"selector");
5565 Builder.AddTextChunk(
"sender");
5576 Results.ExitScope();
5579 Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
5580 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5582 CodeCompleter->includeGlobals());
5584 if (CodeCompleter->includeMacros())
5589 Results.data(), Results.size());
5619 IFace = ObjType->getInterface();
5625 IFace = Ptr->getInterfaceDecl();
5639 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5640 .Case(
"retain", IFace)
5641 .Case(
"strong", IFace)
5642 .Case(
"autorelease", IFace)
5643 .Case(
"copy", IFace)
5644 .Case(
"copyWithZone", IFace)
5645 .Case(
"mutableCopy", IFace)
5646 .Case(
"mutableCopyWithZone", IFace)
5647 .Case(
"awakeFromCoder", IFace)
5648 .Case(
"replacementObjectFromCoder", IFace)
5649 .Case(
"class", IFace)
5650 .Case(
"classForCoder", IFace)
5651 .Case(
"superclass", Super)
5654 return llvm::StringSwitch<ObjCInterfaceDecl *>(Id->
getName())
5656 .Case(
"alloc", IFace)
5657 .Case(
"allocWithZone", IFace)
5658 .Case(
"class", IFace)
5659 .Case(
"superclass", Super)
5680 Sema &
S,
bool NeedSuperKeyword,
5681 ArrayRef<IdentifierInfo *> SelIdents,
5682 ResultBuilder &Results) {
5701 if ((SuperMethod = Cat->getMethod(CurMethod->
getSelector(),
5719 CurP != CurPEnd; ++CurP, ++SuperP) {
5722 (*SuperP)->getType()))
5726 if (!(*CurP)->getIdentifier())
5732 Results.getCodeCompletionTUInfo());
5736 Results.getCompletionContext().getBaseType(),
5740 if (NeedSuperKeyword) {
5741 Builder.AddTypedTextChunk(
"super");
5747 if (NeedSuperKeyword)
5755 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++
I, ++CurP) {
5756 if (I > SelIdents.size())
5759 if (I < SelIdents.size())
5761 Builder.getAllocator().CopyString(
5763 else if (NeedSuperKeyword || I > SelIdents.size()) {
5765 Builder.getAllocator().CopyString(
5768 (*CurP)->getIdentifier()->getName()));
5771 Builder.getAllocator().CopyString(
5774 (*CurP)->getIdentifier()->getName()));
5786 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
5787 CodeCompleter->getCodeCompletionTUInfo(),
5789 getLangOpts().CPlusPlus11
5790 ? &ResultBuilder::IsObjCMessageReceiverOrLambdaCapture
5791 : &ResultBuilder::IsObjCMessageReceiver);
5793 CodeCompletionDeclConsumer Consumer(Results, CurContext);
5794 Results.EnterNewScope();
5796 CodeCompleter->includeGlobals());
5802 if (Iface->getSuperClass()) {
5803 Results.AddResult(Result(
"super"));
5811 Results.ExitScope();
5813 if (CodeCompleter->includeMacros())
5816 Results.data(), Results.size());
5822 bool AtArgumentExpression) {
5826 CDecl = CurMethod->getClassInterface();
5835 if (CurMethod->isInstanceMethod()) {
5839 return CodeCompleteObjCInstanceMessage(S,
nullptr, SelIdents,
5840 AtArgumentExpression,
5849 NamedDecl *ND = LookupSingleName(S, Super, SuperLoc,
5850 LookupOrdinaryName);
5851 if ((CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(ND))) {
5853 }
else if (
TypeDecl *TD = dyn_cast_or_null<TypeDecl>(ND)) {
5856 CDecl = Iface->getInterface();
5857 }
else if (ND && isa<UnresolvedUsingTypenameDecl>(ND)) {
5864 id.setIdentifier(Super, SuperLoc);
5865 ExprResult SuperExpr = ActOnIdExpression(S, SS, TemplateKWLoc,
id,
5867 return CodeCompleteObjCInstanceMessage(S, (
Expr *)SuperExpr.
get(),
5869 AtArgumentExpression);
5878 return CodeCompleteObjCClassMessage(S, Receiver, SelIdents,
5879 AtArgumentExpression,
5886 unsigned NumSelIdents) {
5888 ASTContext &Context = Results.getSema().Context;
5892 Result *ResultsData = Results.data();
5893 for (
unsigned I = 0, N = Results.size(); I != N; ++
I) {
5894 Result &R = ResultsData[
I];
5895 if (R.Kind == Result::RK_Declaration &&
5896 isa<ObjCMethodDecl>(R.Declaration)) {
5897 if (R.Priority <= BestPriority) {
5898 const ObjCMethodDecl *Method = cast<ObjCMethodDecl>(R.Declaration);
5899 if (NumSelIdents <= Method->param_size()) {
5902 if (R.Priority < BestPriority || PreferredType.
isNull()) {
5903 BestPriority = R.Priority;
5904 PreferredType = MyPreferredType;
5914 return PreferredType;
5919 ArrayRef<IdentifierInfo *> SelIdents,
5920 bool AtArgumentExpression,
5922 ResultBuilder &Results) {
5932 CDecl = Interface->getInterface();
5937 Results.EnterNewScope();
5944 Results.Ignore(SuperMethod);
5950 Results.setPreferredSelector(CurMethod->getSelector());
5952 VisitedSelectorSet Selectors;
5955 SemaRef.
CurContext, Selectors, AtArgumentExpression,
5963 for (uint32_t I = 0,
5974 for (Sema::GlobalMethodPool::iterator M = SemaRef.
MethodPool.begin(),
5979 MethList = MethList->getNext()) {
5983 Result R(MethList->getMethod(),
5984 Results.getBasePriority(MethList->getMethod()),
nullptr);
5985 R.StartParameter = SelIdents.size();
5986 R.AllParametersAreInformative =
false;
5987 Results.MaybeAddResult(R, SemaRef.
CurContext);
5992 Results.ExitScope();
5997 bool AtArgumentExpression,
6000 QualType T = this->GetTypeFromParser(Receiver);
6002 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6003 CodeCompleter->getCodeCompletionTUInfo(),
6008 AtArgumentExpression, IsSuper, Results);
6015 if (AtArgumentExpression) {
6018 if (PreferredType.
isNull())
6019 CodeCompleteOrdinaryName(S, PCC_Expression);
6021 CodeCompleteExpression(S, PreferredType);
6026 Results.getCompletionContext(),
6027 Results.data(), Results.size());
6032 bool AtArgumentExpression,
6036 Expr *RecExpr =
static_cast<Expr *
>(Receiver);
6041 ExprResult Conv = DefaultFunctionArrayLvalueConversion(RecExpr);
6044 RecExpr = Conv.
get();
6057 return CodeCompleteObjCClassMessage(S,
6060 AtArgumentExpression, Super);
6065 }
else if (RecExpr && getLangOpts().CPlusPlus) {
6066 ExprResult Conv = PerformContextuallyConvertToObjCPointer(RecExpr);
6068 RecExpr = Conv.
get();
6069 ReceiverType = RecExpr->
getType();
6074 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6075 CodeCompleter->getCodeCompletionTUInfo(),
6077 ReceiverType, SelIdents));
6079 Results.EnterNewScope();
6086 Results.Ignore(SuperMethod);
6092 Results.setPreferredSelector(CurMethod->getSelector());
6095 VisitedSelectorSet Selectors;
6105 CurContext, Selectors, AtArgumentExpression, Results);
6112 for (
auto *I : QualID->quals())
6114 Selectors, AtArgumentExpression, Results);
6121 CurContext, Selectors, AtArgumentExpression,
6125 for (
auto *I : IFacePtr->quals())
6127 Selectors, AtArgumentExpression, Results);
6136 if (ExternalSource) {
6137 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6139 Selector Sel = ExternalSource->GetExternalSelector(I);
6140 if (Sel.
isNull() || MethodPool.count(Sel))
6143 ReadMethodPool(Sel);
6147 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6148 MEnd = MethodPool.end();
6152 MethList = MethList->getNext()) {
6156 if (!Selectors.insert(MethList->getMethod()->getSelector()).second)
6159 Result R(MethList->getMethod(),
6160 Results.getBasePriority(MethList->getMethod()),
nullptr);
6161 R.StartParameter = SelIdents.size();
6162 R.AllParametersAreInformative =
false;
6163 Results.MaybeAddResult(R, CurContext);
6167 Results.ExitScope();
6175 if (AtArgumentExpression) {
6178 if (PreferredType.
isNull())
6179 CodeCompleteOrdinaryName(S, PCC_Expression);
6181 CodeCompleteExpression(S, PreferredType);
6186 Results.getCompletionContext(),
6187 Results.data(),Results.size());
6203 CodeCompleteExpression(S, Data);
6210 if (ExternalSource) {
6211 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
6213 Selector Sel = ExternalSource->GetExternalSelector(I);
6214 if (Sel.
isNull() || MethodPool.count(Sel))
6217 ReadMethodPool(Sel);
6221 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6222 CodeCompleter->getCodeCompletionTUInfo(),
6224 Results.EnterNewScope();
6225 for (GlobalMethodPool::iterator M = MethodPool.begin(),
6226 MEnd = MethodPool.end();
6234 Results.getCodeCompletionTUInfo());
6238 Results.AddResult(
Builder.TakeString());
6242 std::string Accumulator;
6243 for (
unsigned I = 0, N = Sel.
getNumArgs(); I != N; ++
I) {
6244 if (I == SelIdents.size()) {
6245 if (!Accumulator.empty()) {
6248 Accumulator.clear();
6255 Builder.AddTypedTextChunk(
Builder.getAllocator().CopyString( Accumulator));
6256 Results.AddResult(
Builder.TakeString());
6258 Results.ExitScope();
6262 Results.data(), Results.size());
6268 bool OnlyForwardDeclarations,
6269 ResultBuilder &Results) {
6272 for (
const auto *D : Ctx->
decls()) {
6274 if (
const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
6275 if (!OnlyForwardDeclarations || !Proto->hasDefinition())
6276 Results.AddResult(Result(Proto, Results.getBasePriority(Proto),
nullptr),
6277 CurContext,
nullptr,
false);
6283 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6284 CodeCompleter->getCodeCompletionTUInfo(),
6287 if (CodeCompleter->includeGlobals()) {
6288 Results.EnterNewScope();
6296 Results.Ignore(Protocol);
6302 Results.ExitScope();
6307 Results.data(),Results.size());
6311 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6312 CodeCompleter->getCodeCompletionTUInfo(),
6315 if (CodeCompleter->includeGlobals()) {
6316 Results.EnterNewScope();
6322 Results.ExitScope();
6327 Results.data(),Results.size());
6333 bool OnlyForwardDeclarations,
6334 bool OnlyUnimplemented,
6335 ResultBuilder &Results) {
6338 for (
const auto *D : Ctx->
decls()) {
6340 if (
const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
6341 if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
6342 (!OnlyUnimplemented || !Class->getImplementation()))
6343 Results.AddResult(Result(Class, Results.getBasePriority(Class),
nullptr),
6344 CurContext,
nullptr,
false);
6349 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6350 CodeCompleter->getCodeCompletionTUInfo(),
6352 Results.EnterNewScope();
6354 if (CodeCompleter->includeGlobals()) {
6360 Results.ExitScope();
6364 Results.data(),Results.size());
6369 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6370 CodeCompleter->getCodeCompletionTUInfo(),
6372 Results.EnterNewScope();
6376 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6377 if (CurClass && isa<ObjCInterfaceDecl>(CurClass))
6378 Results.Ignore(CurClass);
6380 if (CodeCompleter->includeGlobals()) {
6386 Results.ExitScope();
6390 Results.data(),Results.size());
6394 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6395 CodeCompleter->getCodeCompletionTUInfo(),
6397 Results.EnterNewScope();
6399 if (CodeCompleter->includeGlobals()) {
6405 Results.ExitScope();
6409 Results.data(),Results.size());
6417 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6418 CodeCompleter->getCodeCompletionTUInfo(),
6423 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6425 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6427 for (
const auto *Cat : Class->visible_categories())
6428 CategoryNames.insert(Cat->getIdentifier());
6432 Results.EnterNewScope();
6434 for (
const auto *D : TU->
decls())
6435 if (
const auto *
Category = dyn_cast<ObjCCategoryDecl>(D))
6436 if (CategoryNames.insert(
Category->getIdentifier()).second)
6439 CurContext,
nullptr,
false);
6440 Results.ExitScope();
6444 Results.data(),Results.size());
6456 = LookupSingleName(TUScope, ClassName, ClassNameLoc, LookupOrdinaryName);
6459 return CodeCompleteObjCInterfaceCategory(S, ClassName, ClassNameLoc);
6461 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6462 CodeCompleter->getCodeCompletionTUInfo(),
6468 llvm::SmallPtrSet<IdentifierInfo *, 16> CategoryNames;
6469 Results.EnterNewScope();
6470 bool IgnoreImplemented =
true;
6473 if ((!IgnoreImplemented || !Cat->getImplementation()) &&
6474 CategoryNames.insert(Cat->getIdentifier()).second)
6475 Results.AddResult(Result(Cat, Results.getBasePriority(Cat),
nullptr),
6476 CurContext,
nullptr,
false);
6480 IgnoreImplemented =
false;
6482 Results.ExitScope();
6486 Results.data(),Results.size());
6491 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
6492 CodeCompleter->getCodeCompletionTUInfo(),
6497 = dyn_cast_or_null<ObjCContainerDecl>(CurContext);
6499 (!isa<ObjCImplementationDecl>(Container) &&
6500 !isa<ObjCCategoryImplDecl>(Container)))
6505 for (
const auto *D : Container->decls())
6506 if (
const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
6507 Results.Ignore(PropertyImpl->getPropertyDecl());
6511 Results.EnterNewScope();
6513 = dyn_cast<ObjCImplementationDecl>(Container))
6516 AddedProperties, Results);
6519 cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl(),
6520 false,
false, CurContext,
6521 AddedProperties, Results);
6522 Results.ExitScope();
6526 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)))
6547 = dyn_cast<ObjCImplementationDecl>(Container))
6548 Class = ClassImpl->getClassInterface();
6550 Class = cast<ObjCCategoryImplDecl>(Container)->getCategoryDecl()
6551 ->getClassInterface();
6559 =
Property->getType().getNonReferenceType().getUnqualifiedType();
6562 Results.setPreferredType(PropertyType);
6567 Results.EnterNewScope();
6568 bool SawSimilarlyNamedIvar =
false;
6569 std::string NameWithPrefix;
6570 NameWithPrefix +=
'_';
6571 NameWithPrefix += PropertyName->
getName();
6572 std::string NameWithSuffix = PropertyName->
getName().str();
6573 NameWithSuffix +=
'_';
6577 Results.AddResult(Result(Ivar, Results.getBasePriority(Ivar),
nullptr),
6578 CurContext,
nullptr,
false);
6582 if ((PropertyName == Ivar->getIdentifier() ||
6583 NameWithPrefix == Ivar->
getName() ||
6584 NameWithSuffix == Ivar->getName())) {
6585 SawSimilarlyNamedIvar =
true;
6589 if (Results.size() &&
6590 Results.data()[Results.size() - 1].Kind
6592 Results.data()[Results.size() - 1].Declaration == Ivar)
6593 Results.data()[Results.size() - 1].Priority--;
6598 if (!SawSimilarlyNamedIvar) {
6609 Policy, Allocator));
6611 Results.AddResult(Result(
Builder.TakeString(), Priority,
6615 Results.ExitScope();
6619 Results.data(),Results.size());
6624 typedef llvm::DenseMap<
6633 bool WantInstanceMethods,
6636 bool InOriginalClass =
true) {
6639 if (!IFace->hasDefinition())
6642 IFace = IFace->getDefinition();
6646 = IFace->getReferencedProtocols();
6648 E = Protocols.
end();
6651 KnownMethods, InOriginalClass);
6654 for (
auto *Cat : IFace->visible_categories()) {
6656 KnownMethods,
false);
6660 if (IFace->getSuperClass())
6662 WantInstanceMethods, ReturnType,
6663 KnownMethods,
false);
6669 =
Category->getReferencedProtocols();
6671 E = Protocols.
end();
6674 KnownMethods, InOriginalClass);
6677 if (InOriginalClass &&
Category->getClassInterface())
6679 WantInstanceMethods, ReturnType, KnownMethods,
6685 if (!Protocol->hasDefinition())
6687 Protocol = Protocol->getDefinition();
6688 Container = Protocol;
6692 = Protocol->getReferencedProtocols();
6694 E = Protocols.
end();
6697 KnownMethods,
false);
6703 for (
auto *M : Container->
methods()) {
6704 if (M->isInstanceMethod() == WantInstanceMethods) {
6705 if (!ReturnType.
isNull() &&
6709 KnownMethods[M->getSelector()] =
6710 KnownMethodsMap::mapped_type(M, InOriginalClass);
6718 unsigned ObjCDeclQuals,
6747 bool IsInstanceMethod,
6750 VisitedSelectorSet &KnownSelectors,
6751 ResultBuilder &Results) {
6753 if (!PropName || PropName->
getLength() == 0)
6771 const char *CopiedKey;
6774 :
Allocator(Allocator), Key(Key), CopiedKey(
nullptr) {}
6776 operator const char *() {
6780 return CopiedKey = Allocator.
CopyString(Key);
6782 } Key(Allocator, PropName->
getName());
6785 std::string UpperKey = PropName->
getName();
6786 if (!UpperKey.empty())
6789 bool ReturnTypeMatchesProperty = ReturnType.
isNull() ||
6792 bool ReturnTypeMatchesVoid
6796 if (IsInstanceMethod &&
6797 KnownSelectors.insert(Selectors.getNullarySelector(PropName)).second &&
6803 Builder.AddTypedTextChunk(Key);
6810 if (IsInstanceMethod &&
6811 ((!ReturnType.
isNull() &&
6816 std::string SelectorName = (Twine(
"is") + UpperKey).str();
6818 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6820 if (ReturnType.
isNull()) {
6834 if (IsInstanceMethod && ReturnTypeMatchesVoid &&
6836 std::string SelectorName = (Twine(
"set") + UpperKey).str();
6838 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6839 if (ReturnType.
isNull()) {
6847 Builder.AddTypedTextChunk(
":");
6886 if (IsInstanceMethod &&
6888 std::string SelectorName = (Twine(
"countOf") + UpperKey).str();
6890 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
6892 if (ReturnType.
isNull()) {
6894 Builder.AddTextChunk(
"NSUInteger");
6900 Results.AddResult(Result(
Builder.TakeString(),
6902 UnorderedGetterPriority),
6909 if (IsInstanceMethod &&
6911 std::string SelectorName
6912 = (Twine(
"objectIn") + UpperKey +
"AtIndex").str();
6914 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6915 if (ReturnType.
isNull()) {
6923 Builder.AddTextChunk(
"NSUInteger");
6925 Builder.AddTextChunk(
"index");
6926 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6932 if (IsInstanceMethod &&
6937 ->getName() ==
"NSArray"))) {
6938 std::string SelectorName
6939 = (Twine(Property->
getName()) +
"AtIndexes").str();
6941 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
6942 if (ReturnType.
isNull()) {
6944 Builder.AddTextChunk(
"NSArray *");
6950 Builder.AddTextChunk(
"NSIndexSet *");
6952 Builder.AddTextChunk(
"indexes");
6953 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6959 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6960 std::string SelectorName = (Twine(
"get") + UpperKey).str();
6966 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
6967 if (ReturnType.
isNull()) {
6975 Builder.AddPlaceholderChunk(
"object-type");
6978 Builder.AddTextChunk(
"buffer");
6980 Builder.AddTypedTextChunk(
"range:");
6982 Builder.AddTextChunk(
"NSRange");
6984 Builder.AddTextChunk(
"inRange");
6985 Results.AddResult(Result(
Builder.TakeString(), IndexedGetterPriority,
6993 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
6994 std::string SelectorName = (Twine(
"in") + UpperKey +
"AtIndex").str();
7000 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7001 if (ReturnType.
isNull()) {
7007 Builder.AddTypedTextChunk(
"insertObject:");
7009 Builder.AddPlaceholderChunk(
"object-type");
7012 Builder.AddTextChunk(
"object");
7016 Builder.AddPlaceholderChunk(
"NSUInteger");
7018 Builder.AddTextChunk(
"index");
7019 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
7025 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7026 std::string SelectorName = (Twine(
"insert") + UpperKey).str();
7032 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7033 if (ReturnType.
isNull()) {
7041 Builder.AddTextChunk(
"NSArray *");
7043 Builder.AddTextChunk(
"array");
7045 Builder.AddTypedTextChunk(
"atIndexes:");
7047 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7049 Builder.AddTextChunk(
"indexes");
7050 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
7056 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7057 std::string SelectorName
7058 = (Twine(
"removeObjectFrom") + UpperKey +
"AtIndex").str();
7060 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7061 if (ReturnType.
isNull()) {
7069 Builder.AddTextChunk(
"NSUInteger");
7071 Builder.AddTextChunk(
"index");
7072 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
7078 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7079 std::string SelectorName
7080 = (Twine(
"remove") + UpperKey +
"AtIndexes").str();
7082 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7083 if (ReturnType.
isNull()) {
7091 Builder.AddTextChunk(
"NSIndexSet *");
7093 Builder.AddTextChunk(
"indexes");
7094 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
7100 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7101 std::string SelectorName
7102 = (Twine(
"replaceObjectIn") + UpperKey +
"AtIndex").str();
7108 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7109 if (ReturnType.
isNull()) {
7117 Builder.AddPlaceholderChunk(
"NSUInteger");
7119 Builder.AddTextChunk(
"index");
7121 Builder.AddTypedTextChunk(
"withObject:");
7125 Builder.AddTextChunk(
"object");
7126 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
7132 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7133 std::string SelectorName1
7134 = (Twine(
"replace") + UpperKey +
"AtIndexes").str();
7135 std::string SelectorName2 = (Twine(
"with") + UpperKey).str();
7141 if (KnownSelectors.insert(Selectors.getSelector(2, SelectorIds)).second) {
7142 if (ReturnType.
isNull()) {
7150 Builder.AddPlaceholderChunk(
"NSIndexSet *");
7152 Builder.AddTextChunk(
"indexes");
7156 Builder.AddTextChunk(
"NSArray *");
7158 Builder.AddTextChunk(
"array");
7159 Results.AddResult(Result(
Builder.TakeString(), IndexedSetterPriority,
7166 if (IsInstanceMethod &&
7171 ->getName() ==
"NSEnumerator"))) {
7172 std::string SelectorName = (Twine(
"enumeratorOf") + UpperKey).str();
7174 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7176 if (ReturnType.
isNull()) {
7178 Builder.AddTextChunk(
"NSEnumerator *");
7183 Results.AddResult(Result(
Builder.TakeString(), UnorderedGetterPriority,
7189 if (IsInstanceMethod &&
7191 std::string SelectorName = (Twine(
"memberOf") + UpperKey).str();
7193 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7194 if (ReturnType.
isNull()) {
7196 Builder.AddPlaceholderChunk(
"object-type");
7203 if (ReturnType.
isNull()) {
7204 Builder.AddPlaceholderChunk(
"object-type");
7212 Builder.AddTextChunk(
"object");
7213 Results.AddResult(Result(
Builder.TakeString(), UnorderedGetterPriority,
7220 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7221 std::string SelectorName
7222 = (Twine(
"add") + UpperKey + Twine(
"Object")).str();
7224 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7225 if (ReturnType.
isNull()) {
7233 Builder.AddPlaceholderChunk(
"object-type");
7236 Builder.AddTextChunk(
"object");
7237 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
7243 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7244 std::string SelectorName = (Twine(
"add") + UpperKey).str();
7246 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7247 if (ReturnType.
isNull()) {
7255 Builder.AddTextChunk(
"NSSet *");
7257 Builder.AddTextChunk(
"objects");
7258 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
7264 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7265 std::string SelectorName
7266 = (Twine(
"remove") + UpperKey + Twine(
"Object")).str();
7268 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7269 if (ReturnType.
isNull()) {
7277 Builder.AddPlaceholderChunk(
"object-type");
7280 Builder.AddTextChunk(
"object");
7281 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
7287 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7288 std::string SelectorName = (Twine(
"remove") + UpperKey).str();
7290 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7291 if (ReturnType.
isNull()) {
7299 Builder.AddTextChunk(
"NSSet *");
7301 Builder.AddTextChunk(
"objects");
7302 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
7308 if (IsInstanceMethod && ReturnTypeMatchesVoid) {
7309 std::string SelectorName = (Twine(
"intersect") + UpperKey).str();
7311 if (KnownSelectors.insert(Selectors.getUnarySelector(SelectorId)).second) {
7312 if (ReturnType.
isNull()) {
7320 Builder.AddTextChunk(
"NSSet *");
7322 Builder.AddTextChunk(
"objects");
7323 Results.AddResult(Result(
Builder.TakeString(), UnorderedSetterPriority,
7330 if (!IsInstanceMethod &&
7335 ->getName() ==
"NSSet"))) {
7336 std::string SelectorName
7337 = (Twine(
"keyPathsForValuesAffecting") + UpperKey).str();
7339 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7341 if (ReturnType.
isNull()) {
7343 Builder.AddTextChunk(
"NSSet<NSString *> *");
7354 if (!IsInstanceMethod &&
7358 std::string SelectorName
7359 = (Twine(
"automaticallyNotifiesObserversOf") + UpperKey).str();
7361 if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))
7363 if (ReturnType.
isNull()) {
7377 bool IsInstanceMethod,
7381 QualType ReturnType = GetTypeFromParser(ReturnTy);
7382 Decl *IDecl =
nullptr;
7385 IDecl = cast<Decl>(OCD);
7389 bool IsInImplementation =
false;
7390 if (
Decl *D = IDecl) {
7392 SearchDecl = Impl->getClassInterface();
7393 IsInImplementation =
true;
7395 = dyn_cast<ObjCCategoryImplDecl>(D)) {
7396 SearchDecl = CatImpl->getCategoryDecl();
7397 IsInImplementation =
true;
7402 if (!SearchDecl && S) {
7404 SearchDecl = dyn_cast<ObjCContainerDecl>(DC);
7417 ReturnType, KnownMethods);
7421 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7422 CodeCompleter->getCodeCompletionTUInfo(),
7424 Results.EnterNewScope();
7426 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7427 MEnd = KnownMethods.end();
7431 Results.getCodeCompletionTUInfo());
7435 if (ReturnType.
isNull()) {
7453 P != PEnd; (void)++
P, ++I) {
7456 Builder.AddTypedTextChunk(
":");
7467 ParamType = (*P)->getType();
7469 ParamType = (*P)->getOriginalType();
7474 (*P)->getObjCDeclQualifier(),
7479 Builder.AddTextChunk(
Builder.getAllocator().CopyString( Id->getName()));
7488 if (IsInImplementation && Results.includeCodePatterns()) {
7495 Builder.AddTextChunk(
"return");
7497 Builder.AddPlaceholderChunk(
"expression");
7500 Builder.AddPlaceholderChunk(
"statements");
7507 if (!M->second.getInt())
7510 Results.AddResult(Result(
Builder.TakeString(), Method, Priority));
7517 Containers.push_back(SearchDecl);
7519 VisitedSelectorSet KnownSelectors;
7520 for (KnownMethodsMap::iterator M = KnownMethods.begin(),
7521 MEnd = KnownMethods.end();
7523 KnownSelectors.insert(M->first);
7529 IFace =
Category->getClassInterface();
7533 Containers.push_back(Cat);
7535 for (
unsigned I = 0, N = Containers.size(); I != N; ++
I)
7536 for (
auto *
P : Containers[I]->instance_properties())
7538 KnownSelectors, Results);
7541 Results.ExitScope();
7545 Results.data(),Results.size());
7549 bool IsInstanceMethod,
7550 bool AtParameterName,
7555 if (ExternalSource) {
7556 for (uint32_t I = 0, N = ExternalSource->GetNumExternalSelectors();
7558 Selector Sel = ExternalSource->GetExternalSelector(I);
7559 if (Sel.
isNull() || MethodPool.count(Sel))
7562 ReadMethodPool(Sel);
7568 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7569 CodeCompleter->getCodeCompletionTUInfo(),
7573 Results.setPreferredType(GetTypeFromParser(ReturnTy).getNonReferenceType());
7575 Results.EnterNewScope();
7576 for (GlobalMethodPool::iterator M = MethodPool.begin(),
7577 MEnd = MethodPool.end();
7579 for (
ObjCMethodList *MethList = IsInstanceMethod ? &M->second.first :
7582 MethList = MethList->getNext()) {
7586 if (AtParameterName) {
7588 unsigned NumSelIdents = SelIdents.size();
7590 NumSelIdents <= MethList->getMethod()->param_size()) {
7592 MethList->getMethod()->parameters()[NumSelIdents - 1];
7595 Results.getCodeCompletionTUInfo());
7598 Results.AddResult(
Builder.TakeString());
7605 Result R(MethList->getMethod(),
7606 Results.getBasePriority(MethList->getMethod()),
nullptr);
7607 R.StartParameter = SelIdents.size();
7608 R.AllParametersAreInformative =
false;
7609 R.DeclaringEntity =
true;
7610 Results.MaybeAddResult(R, CurContext);
7614 Results.ExitScope();
7616 if (!AtParameterName && !SelIdents.empty() &&
7617 SelIdents.front()->getName().startswith(
"init")) {
7618 for (
const auto &M : PP.macros()) {
7619 if (M.first->getName() !=
"NS_DESIGNATED_INITIALIZER")
7621 Results.EnterNewScope();
7623 Results.getCodeCompletionTUInfo());
7625 Builder.getAllocator().CopyString(M.first->getName()));
7628 Results.ExitScope();
7634 Results.data(),Results.size());
7638 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7639 CodeCompleter->getCodeCompletionTUInfo(),
7641 Results.EnterNewScope();
7645 Results.getCodeCompletionTUInfo());
7646 Builder.AddTypedTextChunk(
"if");
7648 Builder.AddPlaceholderChunk(
"condition");
7649 Results.AddResult(
Builder.TakeString());
7652 Builder.AddTypedTextChunk(
"ifdef");
7654 Builder.AddPlaceholderChunk(
"macro");
7655 Results.AddResult(
Builder.TakeString());
7658 Builder.AddTypedTextChunk(
"ifndef");
7660 Builder.AddPlaceholderChunk(
"macro");
7661 Results.AddResult(
Builder.TakeString());
7663 if (InConditional) {
7665 Builder.AddTypedTextChunk(
"elif");
7667 Builder.AddPlaceholderChunk(
"condition");
7668 Results.AddResult(
Builder.TakeString());
7671 Builder.AddTypedTextChunk(
"else");
7672 Results.AddResult(
Builder.TakeString());
7675 Builder.AddTypedTextChunk(
"endif");
7676 Results.AddResult(
Builder.TakeString());
7680 Builder.AddTypedTextChunk(
"include");
7683 Builder.AddPlaceholderChunk(
"header");
7685 Results.AddResult(
Builder.TakeString());
7688 Builder.AddTypedTextChunk(
"include");
7691 Builder.AddPlaceholderChunk(
"header");
7693 Results.AddResult(
Builder.TakeString());
7696 Builder.AddTypedTextChunk(
"define");
7698 Builder.AddPlaceholderChunk(
"macro");
7699 Results.AddResult(
Builder.TakeString());
7702 Builder.AddTypedTextChunk(
"define");
7704 Builder.AddPlaceholderChunk(
"macro");
7706 Builder.AddPlaceholderChunk(
"args");
7708 Results.AddResult(
Builder.TakeString());
7711 Builder.AddTypedTextChunk(
"undef");
7713 Builder.AddPlaceholderChunk(
"macro");
7714 Results.AddResult(
Builder.TakeString());
7717 Builder.AddTypedTextChunk(
"line");
7719 Builder.AddPlaceholderChunk(
"number");
7720 Results.AddResult(
Builder.TakeString());
7723 Builder.AddTypedTextChunk(
"line");
7725 Builder.AddPlaceholderChunk(
"number");
7728 Builder.AddPlaceholderChunk(
"filename");
7730 Results.AddResult(
Builder.TakeString());
7733 Builder.AddTypedTextChunk(
"error");
7735 Builder.AddPlaceholderChunk(
"message");
7736 Results.AddResult(
Builder.TakeString());
7739 Builder.AddTypedTextChunk(
"pragma");
7741 Builder.AddPlaceholderChunk(
"arguments");
7742 Results.AddResult(
Builder.TakeString());
7744 if (getLangOpts().ObjC1) {
7746 Builder.AddTypedTextChunk(
"import");
7749 Builder.AddPlaceholderChunk(
"header");
7751 Results.AddResult(
Builder.TakeString());
7754 Builder.AddTypedTextChunk(
"import");
7757 Builder.AddPlaceholderChunk(
"header");
7759 Results.AddResult(
Builder.TakeString());
7763 Builder.AddTypedTextChunk(
"include_next");
7766 Builder.AddPlaceholderChunk(
"header");
7768 Results.AddResult(
Builder.TakeString());
7771 Builder.AddTypedTextChunk(
"include_next");
7774 Builder.AddPlaceholderChunk(
"header");
7776 Results.AddResult(
Builder.TakeString());
7779 Builder.AddTypedTextChunk(
"warning");
7781 Builder.AddPlaceholderChunk(
"message");
7782 Results.AddResult(
Builder.TakeString());
7789 Results.ExitScope();
7793 Results.data(), Results.size());
7797 CodeCompleteOrdinaryName(S,
7803 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7804 CodeCompleter->getCodeCompletionTUInfo(),
7807 if (!IsDefinition && (!CodeCompleter || CodeCompleter->includeMacros())) {
7810 Results.getCodeCompletionTUInfo());
7811 Results.EnterNewScope();
7813 MEnd = PP.macro_end();
7816 M->first->getName()));
7821 Results.ExitScope();
7822 }
else if (IsDefinition) {
7827 Results.data(), Results.size());
7831 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7832 CodeCompleter->getCodeCompletionTUInfo(),
7835 if (!CodeCompleter || CodeCompleter->includeMacros())
7839 Results.EnterNewScope();
7841 Results.getCodeCompletionTUInfo());
7842 Builder.AddTypedTextChunk(
"defined");
7845 Builder.AddPlaceholderChunk(
"macro");
7847 Results.AddResult(
Builder.TakeString());
7848 Results.ExitScope();
7852 Results.data(), Results.size());
7858 unsigned Argument) {
7873 ResultBuilder Results(*
this, CodeCompleter->getAllocator(),
7874 CodeCompleter->getCodeCompletionTUInfo(),
7876 Results.EnterNewScope();
7877 static const char *Platforms[] = {
"macOS",
"iOS",
"watchOS",
"tvOS"};
7878 for (
const char *Platform : llvm::makeArrayRef(Platforms)) {
7881 Twine(Platform) +
"ApplicationExtension")));
7883 Results.ExitScope();
7892 ResultBuilder
Builder(*
this, Allocator, CCTUInfo,
7894 if (!CodeCompleter || CodeCompleter->includeGlobals()) {
7895 CodeCompletionDeclConsumer Consumer(Builder,
7901 if (!CodeCompleter || CodeCompleter->includeMacros())
7905 Results.insert(Results.end(),
7906 Builder.data(), Builder.data() + Builder.size());
pointer operator->() const
An unknown context, in which we are recovering from a parsing error and don't know which completions ...
unsigned getFlags() const
getFlags - Return the flags for this scope.
The receiver is the instance of the superclass object.
SourceManager & getSourceManager() const
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)...
param_const_iterator param_begin() const
bool hasDefinition() const
Determine whether this class has been defined.
static void AddPrettyFunctionResults(const LangOptions &LangOpts, ResultBuilder &Results)
bool isObjCObjectOrInterfaceType() const
const SwitchCase * getNextSwitchCase() const
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
static void MaybeAddSentinel(Preprocessor &PP, const NamedDecl *FunctionOrMethod, CodeCompletionBuilder &Result)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
The receiver is an object instance.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
A C++ namespace alias declaration.
Priority for the Objective-C "_cmd" implicit parameter.
Smart pointer class that efficiently represents Objective-C method names.
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...
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Any kind of method, provided it means other specified criteria.
bool isObjCContainer() const
This is a scope that corresponds to the parameters within a function prototype.
param_iterator param_begin() const
A static_assert or _Static_assert node.
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...
bool includeGlobals() const
Whether to include global (top-level) declaration results.
CodeCompletionString * CreateCodeCompletionString(Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments)
Create a new code-completion string that describes how to insert this result into a program...
bool isMemberPointerType() const
TheContext getContext() const
Code completion occurs within a class, struct, or union.
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
Code completion for a selector, as in an @selector expression.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
const LangOptions & getLangOpts() const
CodeCompleteConsumer::OverloadCandidate ResultCandidate
submodule_iterator submodule_begin()
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
void AddTextChunk(const char *Text)
Add a new text chunk.
static void AddObjCInterfaceResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
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...
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
Code completion where an Objective-C class message is expected.
Adjustment to the "bool" type in Objective-C, where the typedef "BOOL" is preferred.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
static bool isObjCReceiverType(ASTContext &C, QualType T)
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
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...
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
static CharSourceRange getTokenRange(SourceRange R)
Code completion within a type-qualifier list.
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 isRecordType() const
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.
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
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.
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
bool isEnumeralType() const
std::ptrdiff_t difference_type
Defines the clang::MacroInfo and clang::MacroDirective classes.
std::string getAsString() const
void CodeCompleteNaturalLanguage()
pointer(const DeclIndexPair &Value)
The base class of the type hierarchy.
bool isObjCQualifiedClassType() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned getLength() const
Efficiently return the length of this identifier info.
An unspecified code-completion context.
NamespaceDecl - Represent a C++ namespace.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
Wrapper for source info for typedefs.
A C++ non-type template parameter.
ObjCDeclQualifier getObjCDeclQualifier() const
An Objective-C @interface for a category.
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext)
bool isBooleanType() const
A container of type source information.
macro_iterator macro_begin(bool IncludeExternalMacros=true) const
bool isAcceptableNestedNameSpecifier(const NamedDecl *SD, bool *CanCorrect=nullptr)
Determines whether the given declaration is an valid acceptable result for name lookup of a nested-na...
bool isBlockPointerType() const
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
Priority for a member declaration found from the current method or member function.
MacroMap::const_iterator macro_iterator
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)
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef< Expr * > Args)
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.
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...
visible_categories_range visible_categories() const
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.
Information about one declarator, including the parsed type information and the identifier.
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt)
AccessSpecifier getAccess() const
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.
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. ...
decl_iterator decls_end() const
Code completion occurs within an Objective-C implementation or category implementation.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
The entity is not available; any use of it will be an error.
unsigned param_size() const
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
Base wrapper for a particular "section" of type source info.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
unsigned getNumParams() const
void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args)
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)
static void AddFunctionTypeQualsToCompletionString(CodeCompletionBuilder &Result, const FunctionDecl *Function)
One of these records is kept for each identifier that is lexed.
CodeCompletionString * TakeString()
Take the resulting completion string.
method_iterator end_overridden_methods() const
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.
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
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.
A "string" used to describe how code completion can be performed for an entity.
TSS getTypeSpecSign() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
static const TST TST_class
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true)
bool isAnyPointerType() const
An Objective-C @protocol declaration.
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)
ParmVarDecl * getParam(unsigned i) const
Code completion occurs following one or more template headers within a class.
unsigned getIdentifierNamespace() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
CXXRecordDecl * getDefinition() const
const LangOptions & getLangOpts() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
A C++ template template parameter.
void CodeCompleteCase(Scope *S)
An Objective-C instance method.
method_range methods() const
static const TST TST_enum
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
void AddResultTypeChunk(const char *ResultType)
Add a new result-type chunk.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
llvm::DenseMap< Selector, llvm::PointerIntPair< ObjCMethodDecl *, 1, bool > > KnownMethodsMap
bool isNull() const
Determine whether this is the empty selector.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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 SuppressStrongLifetime
When true, suppress printing of the __strong lifetime qualifier in ARC.
Code completion occurs at top-level or namespace context.
Values of this type can be null.
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...
static bool isAcceptableObjCSelector(Selector Sel, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo * > SelIdents, bool AllowSameLength=true)
Represents a C++ unqualified-id that has been parsed.
Represents the results of name lookup.
Divide by this factor when a code-completion result's type exactly matches the type we expect...
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.
const LangOptions & getLangOpts() const
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.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
Code completion occurs following one or more template headers.
void CodeCompleteBracketDeclarator(Scope *S)
static void AddStaticAssertResult(CodeCompletionBuilder &Builder, ResultBuilder &Results, const LangOptions &LangOpts)
QualType getReturnType() const
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.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Whether values of this type can be null is (explicitly) unspecified.
Code completion occurred where a preprocessor directive is expected.
field_range fields() const
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)
Selector getSelector() const
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 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.
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
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)
bool isVariadic() const
Whether this function is variadic.
Scope - A scope is a transient data structure that is used while parsing the program.
bool wantConstructorResults() const
Determines whether we want C++ constructors as results within this context.
submodule_iterator submodule_end()
Priority for a constant value (e.g., enumerator).
QualType getDeclUsageType(ASTContext &C, const NamedDecl *ND)
Determine the type that this declaration will have if it is used as a type or in an expression...
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
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.
TypeClass getTypeClass() const
CodeCompletionTUInfo & getCodeCompletionTUInfo() const
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)...
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.
QualType getBaseType() const
Retrieve the type of the base object in a member-access expression.
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
Represents an ObjC class declaration.
An Objective-C method being used as a property.
ObjCMethodDecl * getMethod() const
Member name lookup, which finds the names of class/struct/union members.
decl_iterator decls_begin() const
detail::InMemoryDirectory::const_iterator I
unsigned getNumParams() const
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...
known_categories_range known_categories() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Priority for a preprocessor macro.
CXCursorKind
Describes the kind of entity that a cursor refers to.
const UnresolvedSetImpl & asUnresolvedSet() const
void CodeCompleteAvailabilityPlatformName()
std::vector< Module * >::iterator submodule_iterator
Code completion occurs within a sequence of declaration specifiers within a function, method, or block.
std::input_iterator_tag iterator_category
void CodeCompleteObjCMethodDecl(Scope *S, bool IsInstanceMethod, ParsedType ReturnType)
A right parenthesis (')').
Code completion where an Objective-C category name is expected.
static void AddStorageSpecifiers(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts, ResultBuilder &Results)
param_iterator param_end() const
const ParmVarDecl *const * param_const_iterator
Sema - This implements semantic analysis and AST building for C.
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression)
Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope...
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, bool UserDefinedConversion=false)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
TST getTypeSpecType() const
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...
QualType getParamType(unsigned i) const
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...
ObjCPropertyAttributeKind getPropertyAttributes() const
Zero-argument (unary) selector.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
DeclarationNameTable DeclarationNames
static void FindImplementableMethods(ASTContext &Context, ObjCContainerDecl *Container, bool WantInstanceMethods, QualType ReturnType, KnownMethodsMap &KnownMethods, bool InOriginalClass=true)
Find all of the methods that reside in the given container (and its superclasses, protocols...
ObjCDeclQualifier getObjCDeclQualifier() const
SmallVector< LambdaCapture, 4 > Captures
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
const CXXMethodDecl *const * method_iterator
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isUnarySelector() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
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.
const ObjCMethodDecl * getMethodDecl() const
CXCursorKind getCursorKindForDecl(const Decl *D)
Determine the libclang cursor kind associated with the given declaration.
Retains information about a block that is currently being parsed.
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...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
Code completion occurred where a new name is expected.
Represents a character-granular source range.
unsigned getNumArgs() const
static PrintingPolicy getCompletionPrintingPolicy(const ASTContext &Context, const Preprocessor &PP)
bool isObjCClassType() const
Declaration of a template type parameter.
void CodeCompleteObjCPropertyDefinition(Scope *S)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
virtual void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Process the finalized code-completion results.
bool includeCodePatterns() const
Whether the code-completion consumer wants to see code patterns.
static bool WantTypesInContext(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts)
Priority for a non-type declaration.
TranslationUnitDecl * getTranslationUnitDecl() const
Code completion occurs within an Objective-C interface, protocol, or category.
Defines the clang::Preprocessor interface.
An Objective-C block property completed as a setter with a block placeholder.
const ParmVarDecl * getParamDecl(unsigned i) const
void CodeCompleteObjCAtVisibility(Scope *S)
An Objective-C @implementation for a category.
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
DeclContext * getDeclContext()
ParmVarDecl *const * param_iterator
internal::Matcher< T > id(StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
If the provided matcher matches a node, binds the node to ID.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Represents a C++ template name within the type system.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
void CodeCompletePreprocessorExpression()
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
bool isObjCIdType() const
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
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 SwitchCase * getSwitchCaseList() const
QualType getType() const
Get the type for which this source info wrapper provides information.
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
QualType stripObjCKindOfType(const ASTContext &ctx) const
Strip Objective-C "__kindof" types from the given type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isInstanceMethod() const
Code completion in a parenthesized expression, which means that we may also have types here in C and ...
bool isFunctionOrMethod() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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.
QualType getObjCIdType() const
Represents the Objective-CC id type.
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...
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.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
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)
const char * CopyString(const Twine &String)
Copy the given string into this allocator.
Priority for a result that isn't likely to be what the user wants, but is included for completeness...
TypeSourceInfo * getTypeSourceInfo() const
void CodeCompleteInitializer(Scope *S, Decl *D)
bool isC99Varargs() const
void CodeCompleteObjCPropertySetter(Scope *S)
const char * getBriefComment() const
const TypeClass * getTypePtr() const
static bool anyNullArguments(ArrayRef< Expr * > Args)
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)
param_const_iterator param_end() const
Priority for the next initialization in a constructor initializer list.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
void CodeCompleteTypeQualifiers(DeclSpec &DS)
ArrayRef< ParmVarDecl * > parameters() const
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.
DeclContext * getEntity() const
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Code completion occurred within a class, struct, or union.
void CodeCompleteObjCAtDirective(Scope *S)
Priority for a send-to-super completion.
SelectorTable & Selectors
const DeclIndexPair * operator->() const
A C++ template type parameter.
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Encodes a location in the source.
enumerator_range enumerators() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Members, declared with object declarations within tag definitions.
method_iterator begin_overridden_methods() const
IdentifierInfo *const * param_iterator
Parameters - The list of parameters for a function-like macro.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt)
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.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
MacroDefinition getMacroDefinition(const IdentifierInfo *II)
ASTContext & getASTContext() const LLVM_READONLY
ASTContext & getASTContext() const
macro_iterator macro_end(bool IncludeExternalMacros=true) const
static const TST TST_union
const Expr * getCond() const
ParsedType getRepAsType() const
TSC getTypeSpecComplex() const
void CodeCompleteReturn(Scope *S)
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
Code completion where the name of an Objective-C class is expected.
Represents a static or instance method of a struct/union/class.
static void AddClassMessageCompletions(Sema &SemaRef, Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper, ResultBuilder &Results)
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)
ArrayRef< ParmVarDecl * > parameters() 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.
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.
The result is a C++ non-static member function whose qualifiers exactly match the object type on whic...
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.
QualType getReturnType() 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.
const T * castAs() const
Member-template castAs<specific type>.
SimplifiedTypeClass getSimplifiedTypeClass(CanQualType T)
Determine the simplified type class of the given canonical type.
TypeLoc getReturnLoc() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
void addParentContext(const DeclContext *DC)
Add the parent context information to this code completion.
bool isFileContext() const
static void AddObjCVisibilityResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
sema::FunctionScopeInfo * getCurFunction() 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.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
llvm::SmallPtrSet< IdentifierInfo *, 16 > AddedPropertiesSet
The set of properties that have already been added, referenced by property name.
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
void CodeCompletePreprocessorMacroName(bool IsDefinition)
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.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
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()
ObjCDeclQualifier getObjCDeclQualifier() const
StringRef getParentName() const
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.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
An Objective-C instance variable.
ParserCompletionContext
Describes the context in which code completion occurs.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
static const TSS TSS_unspecified
LambdaCaptureDefault Default
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...
Priority for a declaration that is in the local scope.
The base class of all kinds of template declarations (e.g., class, function, etc.).
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...
A function or method parameter.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name...
void CodeCompleteTag(Scope *S, unsigned TagSpec)
TypeLoc IgnoreParens() const
bool isFinalSpecified() const
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.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Selector getSelector() const
EnumDecl - Represents an enum.
detail::InMemoryDirectory::const_iterator E
Divide by this factor when a code-completion result's type is similar to the type we expect (e...
static void addThisCompletion(Sema &S, ResultBuilder &Results)
Add a completion for "this", if we're in a member function.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static void HandleCodeCompleteResults(Sema *S, CodeCompleteConsumer *CodeCompleter, CodeCompletionContext Context, CodeCompletionResult *Results, unsigned NumResults)
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
The result is in a base class.
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.
void CodeCompleteNamespaceAliasDecl(Scope *S)
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
void CodeCompleteUsingDirective(Scope *S)
bool isFunctionLike() const
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...
const RawComment * getRawCommentForAnyRedecl(const Decl *D, const Decl **OriginalDecl=nullptr) const
Return the documentation comment attached to a given declaration.
bool isObjCObjectType() const
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.
ObjCMethodDecl * getGetterMethodDecl() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
const T * getAs() const
Member-template getAs<specific type>'.
ExternalSemaSource * getExternalSource() const
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
static void AddTypedNameChunk(ASTContext &Context, const PrintingPolicy &Policy, const NamedDecl *ND, CodeCompletionBuilder &Result)
Add the name of the given declaration.
unsigned getTypeQuals() const
A reference to a member of a struct, union, or class that occurs in some non-expression context...
ObjCMethodDecl * getSetterMethodDecl() const
A module import declaration.
instprop_range instance_properties() const
void CodeCompleteObjCSelector(Scope *S, ArrayRef< IdentifierInfo * > SelIdents)
void AddCurrentParameterChunk(const char *CurrentParameter)
Add a new current-parameter chunk.
enum Kind getKind() const
Retrieve the kind of code-completion context.
A declaration whose specific kind is not exposed via this interface.
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
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
An Objective-C @dynamic definition.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
void * getAsOpaquePtr() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
void CodeCompleteObjCAtStatement(Scope *S)
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement)
ObjCImplementationDecl * getImplementation() const
protocol_range protocols() const
const TypeClass * getTypePtr() const
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)
QualType getPointeeType() const
This is a scope that can contain a declaration.
SourceManager & getSourceManager()
A left parenthesis ('(').
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Code completion occurred within a preprocessor expression.
Code completion occurred where an expression is expected.
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.
BoundNodesTreeBuilder *const Builder
classprop_range class_properties() const
Priority for a nested-name-specifier.
An Objective-C @implementation.
CodeCompleteExpressionData(QualType PreferredType=QualType())
bool isObjCObjectPointerType() const
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< IdentifierInfo * > SelIdents)
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...
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS)
An unspecified code-completion context where we should also add macro completions.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
The parameter type of a method or function.
The selector of the given message exactly matches the selector of the current method, which might imply that some kind of delegation is occurring.
ObjCIvarDecl - Represents an ObjC instance variable.
A left angle bracket ('<').
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
A right angle bracket ('>').
Adjustment for KVC code pattern priorities when it doesn't look like the.
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'.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
bool isOverrideSpecified() const
void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, SmallVectorImpl< CodeCompletionResult > &Results)
Vertical whitespace ('\n' or '\r\n', depending on the platform).
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
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)
ObjCInterfaceDecl * getSuperClass() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
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)
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
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. ...
static OpaquePtr make(QualTypeP)
CodeCompletionAllocator & getAllocator() const
Retrieve the allocator into which the code completion strings should be allocated.
TranslationUnitDecl - The top declaration context.
static void AddObjCImplementationResults(const LangOptions &LangOpts, ResultBuilder &Results, bool NeedAt)
bool isTypeAltiVecVector() const
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
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.
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)
static const TST TST_struct
void AddAnnotation(const char *A)
reference operator*() const
static bool isAcceptableObjCMethod(ObjCMethodDecl *Method, ObjCMethodKind WantKind, ArrayRef< IdentifierInfo * > SelIdents, bool AllowSameLength=true)
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
static void mergeCandidatesWithResults(Sema &SemaRef, SmallVectorImpl< ResultCandidate > &Results, OverloadCandidateSet &CandidateSet, SourceLocation Loc)
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
#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.
EnumDecl * getDefinition() const
friend bool operator==(const iterator &X, const iterator &Y)
llvm::DenseMap< const Stmt *, CFGBlock * > SMap
Priority for a code pattern.
An Objective-C @interface.
A C++ conversion function.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The receiver is a superclass.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
void CodeCompleteAfterIf(Scope *S)
Wrapper for source info for block pointers.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
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.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
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)
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
static ObjCMethodDecl * AddSuperSendCompletion(Sema &S, bool NeedSuperKeyword, ArrayRef< IdentifierInfo * > SelIdents, ResultBuilder &Results)
static QualType getParamType(Sema &SemaRef, ArrayRef< ResultCandidate > Candidates, unsigned N)
Get the type of the Nth parameter from a given set of overload candidates.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Priority for an enumeration constant inside a switch whose condition is of the enumeration type...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.