28#include "llvm/ADT/DenseMap.h"
29#include "llvm/ADT/DenseSet.h"
61 assert(resultClass &&
"unexpected object type!");
66 if (receiverTypeIfCall.
isNull() &&
76 if (receiverTypeIfCall.
isNull())
83 if (!receiverClass)
return false;
86 assert(receiverClass &&
"method not associated with a class!");
102 UnavailableAttr::IR_ARCInitReturnsUnrelated, loc));
107 Diag(loc, diag::err_arc_init_method_unrelated_result_type);
116 if (OldD->
hasAttr<NoEscapeAttr>() && !NewD->
hasAttr<NoEscapeAttr>()) {
117 S.
Diag(NewD->
getLocation(), diag::warn_overriding_method_missing_noescape);
153 CurrentClass = Cat->getClassInterface();
154 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(DC))
155 CurrentClass = Impl->getClassInterface();
157 = dyn_cast<ObjCCategoryImplDecl>(DC))
158 CurrentClass = CatImpl->getClassInterface();
163 diag::warn_related_result_type_compatibility_class)
169 diag::warn_related_result_type_compatibility_protocol)
176 diag::note_related_result_type_family)
181 diag::note_related_result_type_overridden);
184 if ((NewMethod->
hasAttr<NSReturnsRetainedAttr>() !=
185 Overridden->
hasAttr<NSReturnsRetainedAttr>())) {
188 ? diag::err_nsreturns_retained_attribute_mismatch
189 : diag::warn_nsreturns_retained_attribute_mismatch)
193 if ((NewMethod->
hasAttr<NSReturnsNotRetainedAttr>() !=
194 Overridden->
hasAttr<NSReturnsNotRetainedAttr>())) {
197 ? diag::err_nsreturns_retained_attribute_mismatch
198 : diag::warn_nsreturns_retained_attribute_mismatch)
207 ni != ne && oi != oe; ++ni, ++oi) {
210 if (newDecl->
hasAttr<NSConsumedAttr>() !=
211 oldDecl->
hasAttr<NSConsumedAttr>()) {
214 ? diag::err_nsconsumed_attribute_mismatch
215 : diag::warn_nsconsumed_attribute_mismatch);
263 if (method->
hasAttr<NSReturnsRetainedAttr>())
271 if (method->
hasAttr<NSReturnsRetainedAttr>() ||
272 method->
hasAttr<NSReturnsNotRetainedAttr>() ||
273 method->
hasAttr<NSReturnsAutoreleasedAttr>())
286 bool IsCategory =
false;
287 StringRef RealizedPlatform;
289 nullptr, VersionTuple(),
292 if (isa<ObjCMethodDecl>(ND)) {
295 if (RealizedPlatform.empty())
299 if (RealizedPlatform.ends_with(
"_app_extension"))
301 S.
Diag(ImplLoc, diag::warn_unavailable_def);
306 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND)) {
307 if (!CD->getClassInterface()->isDeprecated())
309 ND = CD->getClassInterface();
314 S.
Diag(ImplLoc, diag::warn_deprecated_def)
315 << (isa<ObjCMethodDecl>(ND)
317 : isa<ObjCCategoryDecl>(ND) || IsCategory ? 2
319 if (isa<ObjCMethodDecl>(ND))
324 << (isa<ObjCCategoryDecl>(ND) ?
"category" :
"class");
357 return !
T.getLocalQualifiers().hasObjCLifetime();
377 diag::err_func_def_incomplete_result))
399 if (!Param->isInvalidDecl() &&
402 Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
405 if (Param->getIdentifier())
448 ImplDeclOfMethodDecl = OID->getImplementation();
449 else if (
ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContDeclOfMethodDecl)) {
450 if (CD->IsClassExtension()) {
452 ImplDeclOfMethodDecl = OID->getImplementation();
454 ImplDeclOfMethodDecl = CD->getImplementation();
458 if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
466 IC->getSuperClass() !=
nullptr;
467 }
else if (IC->hasDesignatedInitializers()) {
493 (SuperMethod && SuperMethod->
hasAttr<ObjCRequiresSuperAttr>());
510 ObjCInterfaceValidatorCCC() : CurrentIDecl(nullptr) {}
512 : CurrentIDecl(IDecl) {}
514 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
519 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
520 return std::make_unique<ObjCInterfaceValidatorCCC>(*
this);
532 unsigned NumProtoRefs,
537 for (
unsigned i = 0; i < NumProtoRefs; ++i) {
562 ObjCInterfaceValidatorCCC CCC(IDecl);
567 << SuperName << ClassName);
573 Diag(SuperLoc, diag::err_recursive_superclass)
574 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
578 dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
582 if (SuperClassDecl) {
587 if (PrevDecl && !SuperClassDecl) {
591 dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
595 SuperClassDecl = dyn_cast<ObjCInterfaceDecl>(IDecl);
612 if (!SuperClassDecl) {
613 Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
618 if (!isa_and_nonnull<TypedefNameDecl>(PrevDecl)) {
620 Diag(SuperLoc, diag::err_undef_superclass)
621 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
624 diag::err_forward_superclass,
628 SuperClassDecl =
nullptr;
633 if (SuperClassType.
isNull()) {
634 assert(!SuperClassDecl &&
"Failed to set SuperClassType?");
640 if (!SuperTypeArgs.empty()) {
648 SuperTypeArgsRange.
getEnd(),
660 if (!SuperClassTInfo) {
680 if (parsedTypeBound) {
691 diag::err_objc_type_param_bound_missing_pointer)
692 << typeBound << paramName
711 diag::err_objc_type_param_bound_nonobject)
712 << typeBound << paramName;
715 typeBoundInfo =
nullptr;
724 bool diagnosed =
false;
728 rangeToRemove =
attr.getLocalSourceRange();
729 if (
attr.getTypePtr()->getImmediateNullability()) {
731 diag::err_objc_type_param_bound_explicit_nullability)
732 << paramName << typeBound
742 diag::err_objc_type_param_bound_qualified)
743 << paramName << typeBound
753 if (!quals.
empty()) {
763 if (!typeBoundInfo) {
770 index, paramLoc, paramName, colonLoc,
782 typeParamsIn.size());
788 llvm::SmallDenseMap<IdentifierInfo *, ObjCTypeParamDecl *> knownParams;
789 for (
auto *typeParam : typeParams) {
790 auto known = knownParams.find(typeParam->getIdentifier());
791 if (known != knownParams.end()) {
792 Diag(typeParam->getLocation(), diag::err_objc_type_param_redecl)
793 << typeParam->getIdentifier()
796 typeParam->setInvalidDecl();
798 knownParams.insert(std::make_pair(typeParam->getIdentifier(), typeParam));
810 for (
auto *typeParam : *typeParamList) {
811 if (!typeParam->isInvalidDecl()) {
812 S->RemoveDecl(typeParam);
821 enum class TypeParamListContext {
835 TypeParamListContext newContext) {
837 if (prevTypeParams->
size() != newTypeParams->
size()) {
839 if (newTypeParams->
size() > prevTypeParams->
size()) {
845 S.
Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
846 <<
static_cast<unsigned>(newContext)
847 << (newTypeParams->
size() > prevTypeParams->
size())
848 << prevTypeParams->
size()
849 << newTypeParams->
size();
855 for (
unsigned i = 0, n = prevTypeParams->
size(); i != n; ++i) {
862 newContext != TypeParamListContext::Definition) {
881 auto diag = S.
Diag(diagLoc,
882 diag::err_objc_type_param_variance_conflict)
883 <<
static_cast<unsigned>(newTypeParam->
getVariance())
885 <<
static_cast<unsigned>(prevTypeParam->
getVariance())
894 StringRef newVarianceStr
901 (newVarianceStr +
" ").str());
928 S.
Diag(newBoundRange.
getBegin(), diag::err_objc_type_param_bound_conflict)
952 if (newContext == TypeParamListContext::ForwardDeclaration ||
953 newContext == TypeParamListContext::Definition) {
961 diag::err_objc_type_param_bound_missing)
964 << (newContext == TypeParamListContext::ForwardDeclaration)
983 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
986 assert(ClassName &&
"Missing class identifier");
993 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
994 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
1021 if (typeParamList) {
1025 TypeParamListContext::Definition)) {
1026 typeParamList =
nullptr;
1029 Diag(ClassLoc, diag::err_objc_parameterized_forward_class_first)
1031 Diag(prevTypeParamList->getLAngleLoc(), diag::note_previous_decl)
1036 for (
auto *typeParam : *prevTypeParamList) {
1037 clonedTypeParams.push_back(
1041 typeParam->getVariance(),
1043 typeParam->getIndex(),
1045 typeParam->getIdentifier(),
1060 typeParamList, PrevIDecl, ClassLoc);
1066 SkipBody->
New = IDecl;
1069 Diag(AtInterfaceLoc, diag::err_duplicate_class_def)
1071 Diag(Def->getLocation(), diag::note_previous_definition);
1099 ClassName, ClassLoc,
1100 SuperName, SuperLoc, SuperTypeArgs,
1101 SuperTypeArgsRange);
1109 NumProtoRefs, ProtoLocs);
1134 if (
const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) {
1135 QualType T = TDecl->getUnderlyingType();
1138 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end());
1143 ProtocolLocs.append(OPT->getNumProtocols(), SuperLoc);
1160 Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
1169 dyn_cast_or_null<TypedefNameDecl>(CDeclU)) {
1170 QualType T = TDecl->getUnderlyingType();
1173 ClassName = IDecl->getIdentifier();
1182 Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
1205 E = PList.
end(); I != E; ++I) {
1208 if (PDecl->getIdentifier() == PName) {
1209 Diag(Ploc, diag::err_protocol_has_circular_dependency);
1210 Diag(PrevLoc, diag::note_previous_definition);
1214 if (!PDecl->hasDefinition())
1218 PDecl->getLocation(), PDecl->getReferencedProtocols()))
1232 assert(ProtocolName &&
"Missing protocol identifier");
1242 ProtocolLoc, AtProtoInterfaceLoc,
1247 SkipBody->
New = PDecl;
1251 Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName;
1252 Diag(Def->getLocation(), diag::note_previous_definition);
1267 ProtocolName, ProtocolLoc, PrevDecl->
getLocation(), PList);
1272 ProtocolLoc, AtProtoInterfaceLoc,
1287 if (!err && NumProtoRefs ) {
1290 NumProtoRefs, ProtoLocs);
1304 UndefinedProtocol = PDecl;
1310 UndefinedProtocol = PI;
1336 Diag(Pair.second, diag::err_undeclared_protocol) << Pair.first;
1345 if (!ForObjCContainer) {
1354 if (WarnOnDeclarations &&
1356 Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first;
1357 Diag(UndefinedProtocol->
getLocation(), diag::note_protocol_decl_undefined)
1358 << UndefinedProtocol;
1360 Protocols.push_back(PDecl);
1367class ObjCTypeArgOrProtocolValidatorCCC final
1372 ObjCTypeArgOrProtocolValidatorCCC(
ASTContext &context,
1374 : Context(context), LookupKind(lookupKind) { }
1376 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
1390 if (isa<RecordDecl>(typeDecl) && !Context.
getLangOpts().CPlusPlus)
1396 if (
type->isObjCObjectPointerType() ||
1397 type->isBlockPointerType() ||
1398 type->isDependentType() ||
1399 type->isObjCObjectType())
1416 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
1417 return std::make_unique<ObjCTypeArgOrProtocolValidatorCCC>(*
this);
1426 bool SelectProtocolFirst) {
1427 Diag(TypeArgLoc, diag::err_objc_type_args_and_protocols)
1428 << SelectProtocolFirst << TypeArgId << ProtocolId
1445 bool warnOnIncompleteProtocols) {
1448 unsigned numProtocolsResolved = 0;
1449 auto resolvedAsProtocols = [&] {
1450 assert(numProtocolsResolved == identifiers.size() &&
"Unresolved protocols");
1457 bool allAreTypeNames =
false;
1461 baseClass = objcObjectType->getInterface();
1464 if (typeParams->size() == numProtocolsResolved) {
1466 allAreTypeNames =
true;
1473 for (
unsigned i = 0, n = protocols.size(); i != n; ++i) {
1478 if (!warnOnIncompleteProtocols) {
1490 if (warnOnIncompleteProtocols &&
1492 Diag(identifierLocs[i], diag::warn_undef_protocolref)
1501 if (allAreTypeNames) {
1504 if (isa<ObjCInterfaceDecl>(
decl)) {
1506 firstClassNameLoc = identifierLocs[i];
1507 }
else if (!isa<TypeDecl>(
decl)) {
1509 allAreTypeNames =
false;
1512 allAreTypeNames =
false;
1521 if (allAreTypeNames && firstClassNameLoc.
isValid()) {
1524 bool allProtocolsDeclared =
true;
1525 for (
auto *proto : protocols) {
1527 allProtocolsDeclared =
false;
1532 if (allProtocolsDeclared) {
1533 Diag(firstClassNameLoc, diag::warn_objc_redundant_qualified_class_type)
1540 protocolLAngleLoc = lAngleLoc;
1541 protocolRAngleLoc = rAngleLoc;
1542 assert(protocols.size() == identifierLocs.size());
1546 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1548 protocols.push_back(proto);
1550 ++numProtocolsResolved;
1554 if (numProtocolsResolved == identifiers.size())
1555 return resolvedAsProtocols();
1561 typedef llvm::PointerUnion<TypeDecl *, ObjCInterfaceDecl *> TypeOrClassDecl;
1563 unsigned numTypeDeclsResolved = 0;
1564 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1568 typeDecls.push_back(TypeOrClassDecl());
1572 if (
auto typeDecl = dyn_cast<TypeDecl>(
decl)) {
1573 typeDecls.push_back(typeDecl);
1574 ++numTypeDeclsResolved;
1578 if (
auto objcClass = dyn_cast<ObjCInterfaceDecl>(
decl)) {
1579 typeDecls.push_back(objcClass);
1580 ++numTypeDeclsResolved;
1584 typeDecls.push_back(TypeOrClassDecl());
1591 auto resolveTypeReference = [&](TypeOrClassDecl typeDecl,
SourceLocation loc)
1595 const char* prevSpec;
1598 if (
auto *actualTypeDecl = typeDecl.dyn_cast<
TypeDecl *>())
1626 Diag(loc, diag::err_objc_type_arg_missing_star)
1637 auto resolvedAsTypeDecls = [&] {
1641 assert(numTypeDeclsResolved == identifiers.size() &&
"Unresolved type decl");
1643 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1645 TypeResult type = resolveTypeReference(typeDecls[i], identifierLocs[i]);
1646 if (!
type.isUsable()) {
1651 typeArgs.push_back(
type.get());
1654 typeArgsLAngleLoc = lAngleLoc;
1655 typeArgsRAngleLoc = rAngleLoc;
1660 if (numTypeDeclsResolved == identifiers.size())
1661 return resolvedAsTypeDecls();
1667 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1670 if (protocols[i] || typeDecls[i]) {
1676 if (protocols[i] && typeDecls[i])
1699 identifiers[i], identifierLocs[i],
1700 protocols[i] !=
nullptr);
1708 ObjCTypeArgOrProtocolValidatorCCC CCC(
Context, lookupKind);
1716 PDiag(diag::err_undeclared_protocol_suggest)
1719 protocols[i] = proto;
1720 ++numProtocolsResolved;
1727 PDiag(diag::err_unknown_typename_suggest)
1730 typeDecls[i] = typeDecl;
1731 ++numTypeDeclsResolved;
1738 PDiag(diag::err_unknown_type_or_class_name_suggest)
1739 << identifiers[i] <<
true);
1741 typeDecls[i] = objcClass;
1742 ++numTypeDeclsResolved;
1748 Diag(identifierLocs[i],
1749 (lookupKind ==
LookupAnyName ? diag::err_objc_type_arg_missing
1751 : diag::err_unknown_typename))
1760 if (numProtocolsResolved == identifiers.size())
1761 return resolvedAsProtocols();
1764 assert(numTypeDeclsResolved == identifiers.size() &&
"Not all types?");
1765 return resolvedAsTypeDecls();
1776 llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
1777 for (
auto *MD : ID->methods())
1778 MethodMap[MD->getSelector()] = MD;
1780 if (MethodMap.empty())
1782 for (
const auto *Method : CAT->
methods()) {
1783 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
1787 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
1788 << Method->getDeclName();
1806 IdentPair.second, AtProtocolLoc,
1818 DeclsInGroup.push_back(PDecl);
1828 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
1838 diag::err_category_forward_interface,
1839 CategoryName ==
nullptr)) {
1844 ClassLoc, CategoryLoc, CategoryName,
1845 IDecl, typeParamList);
1850 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1856 Diag(ClassLoc, diag::err_class_extension_after_impl) << ClassName;
1858 diag::note_implementation_declared);
1866 Diag(CategoryLoc, diag::warn_dup_category_def)
1867 << ClassName << CategoryName;
1868 Diag(
Previous->getLocation(), diag::note_previous_definition);
1873 if (typeParamList) {
1877 ? TypeParamListContext::Category
1878 : TypeParamListContext::Extension))
1879 typeParamList =
nullptr;
1882 diag::err_objc_parameterized_category_nonclass)
1883 << (CategoryName !=
nullptr)
1887 typeParamList =
nullptr;
1892 ClassLoc, CategoryLoc, CategoryName, IDecl,
1905 NumProtoRefs, ProtoLocs);
1943 ClassLoc, AtCatImplLoc, CatLoc);
1946 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1949 diag::err_undef_interface)) {
1961 if (IDecl && IDecl->
hasAttr<ObjCRuntimeVisibleAttr>()) {
1962 Diag(ClassLoc, diag::err_objc_runtime_visible_category)
1969 Diag(ClassLoc, diag::err_dup_implementation_category) << ClassName
1972 diag::note_previous_definition);
1997 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1998 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
2000 }
else if ((IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl))) {
2004 diag::warn_undef_interface);
2008 ObjCInterfaceValidatorCCC CCC{};
2017 PDiag(diag::warn_undef_interface_suggest) << ClassName,
2020 Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
2026 if (SuperClassname) {
2030 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
2031 Diag(SuperClassLoc, diag::err_redefinition_different_kind)
2035 SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
2039 Diag(SuperClassLoc, diag::err_undef_superclass)
2040 << SuperClassname << ClassName;
2044 Diag(SuperClassLoc, diag::err_conflicting_super_class)
2083 ClassLoc, AtClassImplLoc, SuperClassLoc);
2096 Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
2098 diag::note_previous_definition);
2112 Diag(ClassLoc, diag::err_objc_runtime_visible_subclass)
2124 DeclsInGroup.reserve(Decls.size() + 1);
2126 for (
unsigned i = 0, e = Decls.size(); i != e; ++i) {
2127 Decl *Dcl = Decls[i];
2132 DeclsInGroup.push_back(Dcl);
2135 DeclsInGroup.push_back(ObjCImpDecl);
2143 assert(ImpDecl &&
"missing implementation decl");
2153 for (
unsigned i = 0, e = numIvars; i != e; ++i) {
2170 assert(ivars &&
"missing @implementation ivars");
2174 for (
unsigned i = 0; i < numIvars; i++) {
2179 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2187 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
2204 for (; numIvars > 0 && IVI != IVE; ++IVI) {
2207 assert (ImplIvar &&
"missing implementation ivar");
2208 assert (ClsIvar &&
"missing class ivar");
2220 diag::err_conflicting_ivar_bitwidth)
2223 diag::note_previous_definition);
2235 Diag(ivars[j]->getLocation(), diag::err_inconsistent_ivar_count);
2236 else if (IVI != IVE)
2237 Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
2264 std::string FixItStr;
2265 llvm::raw_string_ostream Out(FixItStr);
2276 S.
Diag(MethodLoc, diag::note_method_declared_at) << method;
2352 (y &
~Decl::OBJC_TQ_CSNullability);
2358 bool IsProtocolMethodDecl,
2359 bool IsOverridingMode,
2361 if (IsProtocolMethodDecl &&
2367 ? diag::warn_conflicting_overriding_ret_type_modifiers
2368 : diag::warn_conflicting_ret_type_modifiers))
2377 if (Warn && IsOverridingMode &&
2385 diag::warn_conflicting_nullability_attr_overriding_ret_types)
2402 IsOverridingMode ? diag::warn_conflicting_overriding_ret_types
2403 : diag::warn_conflicting_ret_types;
2419 IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types
2420 : diag::warn_non_covariant_ret_types;
2429 ? diag::note_previous_declaration
2430 : diag::note_previous_definition)
2440 bool IsProtocolMethodDecl,
2441 bool IsOverridingMode,
2443 if (IsProtocolMethodDecl &&
2447 if (IsOverridingMode)
2449 diag::warn_conflicting_overriding_param_modifiers)
2453 diag::warn_conflicting_param_modifiers)
2465 if (Warn && IsOverridingMode &&
2469 diag::warn_conflicting_nullability_attr_overriding_param_types)
2484 IsOverridingMode ? diag::warn_conflicting_overriding_param_types
2485 : diag::warn_conflicting_param_types;
2501 IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types
2502 : diag::warn_non_contravariant_param_types;
2508 << MethodImpl->
getDeclName() << IfaceTy << ImplTy;
2510 (IsOverridingMode ? diag::note_previous_declaration
2511 : diag::note_previous_definition))
2522 if (implFamily == declFamily)
return false;
2534 unsigned errorID = diag::err_arc_lost_method_convention;
2535 unsigned noteID = diag::note_arc_lost_method_convention;
2538 family = implFamily;
2539 errorID = diag::err_arc_gained_method_convention;
2540 noteID = diag::note_arc_gained_method_convention;
2544 enum FamilySelector {
2545 F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new
2547 FamilySelector familySelector = FamilySelector();
2550 case OMF_None: llvm_unreachable(
"logic error, no method convention");
2564 case OMF_init: familySelector = F_init;
break;
2565 case OMF_alloc: familySelector = F_alloc;
break;
2566 case OMF_copy: familySelector = F_copy;
break;
2568 case OMF_new: familySelector = F_new;
break;
2571 enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn };
2572 ReasonSelector reasonSelector;
2577 reasonSelector = R_UnrelatedReturn;
2579 reasonSelector = R_NonObjectReturn;
2583 S.
Diag(
decl->getLocation(), noteID) <<
int(familySelector) <<
int(reasonSelector);
2590 bool IsProtocolMethodDecl) {
2596 IsProtocolMethodDecl,
false,
2602 IM != EM && IF != EF; ++IM, ++IF) {
2604 IsProtocolMethodDecl,
false,
true);
2609 diag::warn_conflicting_variadic);
2616 bool IsProtocolMethodDecl) {
2619 IsProtocolMethodDecl,
true,
2625 IM != EM && IF != EF; ++IM, ++IF) {
2627 IsProtocolMethodDecl,
true,
true);
2632 diag::warn_conflicting_overriding_variadic);
2641 bool IsProtocolMethodDecl) {
2650 if (MethodDecl->
hasAttr<UnavailableAttr>() ||
2651 MethodDecl->
hasAttr<DeprecatedAttr>())
2655 IsProtocolMethodDecl,
false,
false);
2660 IM != EM && IF != EF; ++IM, ++IF) {
2663 IsProtocolMethodDecl,
false,
false);
2675 diag::warn_category_method_impl_match);
2692 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>())
2694 for (
const auto *PI : PDecl->
protocols())
2720 : dyn_cast<ObjCInterfaceDecl>(CDecl);
2721 assert (IDecl &&
"CheckProtocolMethodDefs - IDecl is null");
2737 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>()) {
2738 if (!ProtocolsExplictImpl) {
2760 if (InsMap.count(fISelector))
2779 if (method->getImplementationControl() !=
2781 !method->isPropertyAccessor() &&
2782 !InsMap.count(method->getSelector()) &&
2784 method->getSelector(),
true ,
2797 method->getSelector(),
true ,
2799 if (
C || MethodInClass->isPropertyAccessor())
2801 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2809 if (method->getImplementationControl() !=
2811 !ClsMap.count(method->getSelector()) &&
2813 method->getSelector(),
false ,
2815 true ,
nullptr ))) {
2823 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2832 ProtocolsExplictImpl);
2844 bool &IncompleteImpl,
2845 bool ImmediateClass,
2846 bool WarnCategoryMethodImpl) {
2850 if (!InsMapSeen.insert(I->getSelector()).second)
2852 if (!I->isPropertyAccessor() &&
2853 !InsMap.count(I->getSelector())) {
2856 diag::warn_undef_method_impl);
2862 "Expected to find the method through lookup as well");
2864 if (ImpMethodDecl) {
2868 if (!WarnCategoryMethodImpl)
2870 isa<ObjCProtocolDecl>(CDecl));
2871 else if (!I->isPropertyAccessor())
2880 if (!ClsMapSeen.insert(I->getSelector()).second)
2882 if (!I->isPropertyAccessor() &&
2883 !ClsMap.count(I->getSelector())) {
2886 diag::warn_undef_method_impl);
2891 "Expected to find the method through lookup as well");
2893 if (ImpMethodDecl) {
2897 if (!WarnCategoryMethodImpl)
2899 isa<ObjCProtocolDecl>(CDecl));
2900 else if (!I->isPropertyAccessor())
2909 for (
auto *PI : PD->protocols())
2911 IMPDecl, PI, IncompleteImpl,
false,
2912 WarnCategoryMethodImpl);
2919 if (!WarnCategoryMethodImpl) {
2920 for (
auto *Cat : I->visible_categories())
2922 IMPDecl, Cat, IncompleteImpl,
2923 ImmediateClass && Cat->IsClassExtension(),
2924 WarnCategoryMethodImpl);
2927 for (
auto *Ext : I->visible_extensions())
2929 IMPDecl, Ext, IncompleteImpl,
false,
2930 WarnCategoryMethodImpl);
2934 for (
auto *PI : I->all_referenced_protocols())
2936 IMPDecl, PI, IncompleteImpl,
false,
2937 WarnCategoryMethodImpl);
2941 if (!WarnCategoryMethodImpl && I->getSuperClass())
2944 I->getSuperClass(), IncompleteImpl,
false);
2975 if (SuperIDecl && SuperIDecl->
lookupMethod(Sel,
false))
2979 if (InsMap.empty() && ClsMap.empty())
2983 bool IncompleteImpl =
false;
2986 IncompleteImpl,
false,
2992 bool IncompleteImpl) {
2997 InsMap.insert(I->getSelector());
3005 const auto *
P = PImpl->getPropertyDecl();
3008 InsMap.insert(
P->getGetterName());
3009 if (!
P->getSetterName().isNull())
3010 InsMap.insert(
P->getSetterName());
3017 bool SynthesizeProperties =
LangOpts.ObjCDefaultSynthProperties &&
3019 !IDecl->isObjCRequiresPropertyDefs();
3028 ClsMap.insert(I->getSelector());
3035 IncompleteImpl,
true);
3040 dyn_cast<ObjCCategoryImplDecl>(IMPDecl))
3051 for (
auto *PI : I->all_referenced_protocols())
3053 ClsMap, I, ExplicitImplProtocols);
3057 if (!
C->IsClassExtension()) {
3058 for (
auto *
P :
C->protocols())
3060 ClsMap, CDecl, ExplicitImplProtocols);
3065 llvm_unreachable(
"invalid ObjCContainerDecl type.");
3075 for (
unsigned i = 0; i != NumElts; ++i) {
3080 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
3090 Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
3098 Diag(AtClassLoc, diag::warn_forward_class_redefinition)
3108 = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
3130 if (PrevIDecl && TypeParams) {
3134 *
this, PrevTypeParams, TypeParams,
3135 TypeParamListContext::ForwardDeclaration)) {
3136 TypeParams =
nullptr;
3140 Diag(IdentLocs[i], diag::err_objc_parameterized_forward_class)
3143 Diag(Def->getLocation(), diag::note_defined_here)
3146 TypeParams =
nullptr;
3152 ClassName, TypeParams, PrevIDecl,
3161 DeclsInGroup.push_back(IDecl);
3169 const Type *left,
const Type *right);
3178 if (left == right)
return true;
3201 if (isa<VectorType>(left))
return isa<VectorType>(right);
3202 if (isa<VectorType>(right))
return false;
3225 return (leftSK == rightSK);
3231 assert(lt && rt && lt != rt);
3233 if (!isa<RecordType>(lt) || !isa<RecordType>(rt))
return false;
3234 RecordDecl *left = cast<RecordType>(lt)->getDecl();
3235 RecordDecl *right = cast<RecordType>(rt)->getDecl();
3241 if ((isa<CXXRecordDecl>(left) && !cast<CXXRecordDecl>(left)->isPOD()) ||
3242 (isa<CXXRecordDecl>(right) && !cast<CXXRecordDecl>(right)->isPOD()))
3257 for (; li != le && ri != re; ++li, ++ri) {
3258 if (!
matchTypes(Context, strategy, li->getType(), ri->getType()))
3261 return (li == le && ri == re);
3282 (left->
hasAttr<NSReturnsRetainedAttr>()
3283 != right->
hasAttr<NSReturnsRetainedAttr>() ||
3284 left->
hasAttr<NSConsumesSelfAttr>()
3285 != right->
hasAttr<NSConsumesSelfAttr>()))
3292 for (; li != le && ri != re; ++li, ++ri) {
3293 assert(ri != right->
param_end() &&
"Param mismatch");
3300 lparm->
hasAttr<NSConsumedAttr>() != rparm->hasAttr<NSConsumedAttr>())
3308 auto *MethodProtocol = dyn_cast<ObjCProtocolDecl>(Method->
getDeclContext());
3309 auto *MethodInListProtocol =
3313 if ((MethodProtocol && !MethodInListProtocol) ||
3314 (!MethodProtocol && MethodInListProtocol))
3317 if (MethodProtocol && MethodInListProtocol)
3323 return MethodInterface == MethodInListInterface;
3332 if (!CD->IsClassExtension() && List->getBits() < 2)
3333 List->setBits(List->getBits() + 1);
3336 if (List->getMethod() ==
nullptr) {
3337 List->setMethod(Method);
3338 List->setNext(
nullptr);
3346 for (; List;
Previous = List, List = List->getNext()) {
3363 if (!SameDeclaration ||
3369 List->setHasMoreThanOneDecl(
true);
3374 !ListWithSameDeclaration && !List->getMethod()->isDeprecated())
3375 ListWithSameDeclaration = List;
3378 !ListWithSameDeclaration &&
3380 ListWithSameDeclaration = List;
3394 List->setHasMoreThanOneDecl(
true);
3401 List->setMethod(Method);
3407 List->setMethod(Method);
3418 if (ListWithSameDeclaration) {
3421 ListWithSameDeclaration->
setMethod(Method);
3422 ListWithSameDeclaration->
setNext(List);
3442void Sema::AddMethodToGlobalPool(
ObjCMethodDecl *Method,
bool impl,
3460 ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
3497 assert(BoundInterface &&
"unexpected object type!");
3501 auto *MethodProtocol = dyn_cast<ObjCProtocolDecl>(Method->
getDeclContext());
3502 if (MethodProtocol) {
3512 return MethodInterface == BoundInterface ||
3513 MethodInterface->isSuperClassOf(BoundInterface) ||
3514 BoundInterface->isSuperClassOf(MethodInterface);
3516 llvm_unreachable(
"unknown method context");
3523 bool InstanceFirst,
bool CheckTheOther,
3536 if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) {
3538 Methods.push_back(M->getMethod());
3542 if (!Methods.empty())
3543 return Methods.size() > 1;
3552 if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) {
3554 Methods.push_back(M->getMethod());
3557 return Methods.size() > 1;
3565 FilteredMethods.push_back(BestMethod);
3567 for (
auto *M : Methods)
3568 if (M != BestMethod && !M->
hasAttr<UnavailableAttr>())
3569 FilteredMethods.push_back(M);
3571 if (FilteredMethods.size() > 1)
3586 bool receiverIdOrClass,
3596 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
3599 if (M->getMethod() && M->getMethod()->isUnconditionallyVisible())
3600 return M->getMethod();
3607 bool receiverIdOrClass) {
3609 bool issueDiagnostic =
false, issueError =
false;
3613 bool strictSelectorMatch =
3614 receiverIdOrClass &&
3616 if (strictSelectorMatch) {
3617 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3619 issueDiagnostic =
true;
3628 if (!strictSelectorMatch ||
3629 (issueDiagnostic &&
getLangOpts().ObjCAutoRefCount))
3630 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3634 issueDiagnostic =
true;
3641 if (issueDiagnostic) {
3643 Diag(R.
getBegin(), diag::err_arc_multiple_method_decl) << Sel << R;
3644 else if (strictSelectorMatch)
3645 Diag(R.getBegin(), diag::warn_strict_multiple_method_decl) << Sel << R;
3647 Diag(R.getBegin(), diag::warn_multiple_method_decl) << Sel << R;
3649 Diag(Methods[0]->getBeginLoc(),
3650 issueError ? diag::note_possibility : diag::note_using)
3651 << Methods[0]->getSourceRange();
3652 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3653 Diag(Methods[I]->getBeginLoc(), diag::note_also_found)
3654 << Methods[I]->getSourceRange();
3666 Method = Method->getNext())
3667 if (Method->getMethod() &&
3670 return Method->getMethod();
3673 Method = Method->getNext())
3674 if (Method->getMethod() &&
3677 return Method->getMethod();
3685 const unsigned MaxEditDistance = 1;
3686 unsigned BestEditDistance = MaxEditDistance + 1;
3689 unsigned MinPossibleEditDistance =
abs((
int)MethodName.size() - (
int)Typo.size());
3690 if (MinPossibleEditDistance > 0 &&
3691 Typo.size() / MinPossibleEditDistance < 1)
3693 unsigned EditDistance = Typo.edit_distance(MethodName,
true, MaxEditDistance);
3694 if (EditDistance > MaxEditDistance)
3696 if (EditDistance == BestEditDistance)
3697 BestMethod.push_back(Method);
3698 else if (EditDistance < BestEditDistance) {
3700 BestMethod.push_back(Method);
3719 bool ObjectIsId =
true, ObjectIsClass =
true;
3721 ObjectIsId = ObjectIsClass =
false;
3726 ObjectType =
QualType(ObjCPtr->getInterfaceType(), 0);
3727 ObjectIsId = ObjectIsClass =
false;
3730 ObjectIsClass =
false;
3740 if (M->getMethod() &&
3741 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3742 (M->getMethod()->getSelector() != Sel)) {
3744 Methods.push_back(M->getMethod());
3745 else if (!ObjectIsClass &&
3748 Methods.push_back(M->getMethod());
3752 if (M->getMethod() &&
3753 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3754 (M->getMethod()->getSelector() != Sel)) {
3756 Methods.push_back(M->getMethod());
3757 else if (!ObjectIsId &&
3760 Methods.push_back(M->getMethod());
3765 for (
unsigned i = 0, e = Methods.size(); i < e; i++) {
3769 return (SelectedMethods.size() == 1) ? SelectedMethods[0] :
nullptr;
3779 for (
auto *Ivar : ID->ivars()) {
3780 if (Ivar->isInvalidDecl())
3785 Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
3787 Ivar->setInvalidDecl();
3797 for (
auto ivar = ID->getClassInterface()->all_declared_ivar_begin();
3798 ivar; ivar = ivar->getNextIvar()) {
3799 if (ivar->isInvalidDecl())
continue;
3802 S.
Diag(ivar->getLocation(), diag::err_arc_weak_disabled);
3804 S.
Diag(ivar->getLocation(), diag::err_arc_weak_no_runtime);
3816 for (
auto ivar = ID->all_declared_ivar_begin(); ivar;
3817 ivar = ivar->getNextIvar()) {
3818 if (ivar->isInvalidDecl())
3824 S.
Diag(ivar->getLocation(), diag::err_flexible_array_arc_retainable);
3825 ivar->setInvalidDecl();
3832 case Decl::ObjCInterface:
3834 case Decl::ObjCProtocol:
3836 case Decl::ObjCCategory:
3837 if (cast<ObjCCategoryDecl>(
CurContext)->IsClassExtension())
3840 case Decl::ObjCImplementation:
3842 case Decl::ObjCCategoryImpl:
3854 return (RecordTy && RecordTy->getDecl()->hasFlexibleArrayMember());
3861 if ((IntfDecl = dyn_cast<ObjCInterfaceDecl>(OCD))) {
3862 Ivars = IntfDecl->
ivars();
3863 }
else if (
auto *ImplDecl = dyn_cast<ObjCImplementationDecl>(OCD)) {
3864 IntfDecl = ImplDecl->getClassInterface();
3865 Ivars = ImplDecl->
ivars();
3866 }
else if (
auto *CategoryDecl = dyn_cast<ObjCCategoryDecl>(OCD)) {
3867 if (CategoryDecl->IsClassExtension()) {
3868 IntfDecl = CategoryDecl->getClassInterface();
3869 Ivars = CategoryDecl->
ivars();
3874 if (!isa<ObjCInterfaceDecl>(OCD)) {
3875 for (
auto *ivar : Ivars) {
3877 S.
Diag(ivar->getLocation(), diag::warn_variable_sized_ivar_visibility)
3878 << ivar->getDeclName() << ivar->getType();
3890 if (ivar->isInvalidDecl() || !ivar->getNextIvar())
3893 bool IsInvalidIvar =
false;
3895 S.
Diag(ivar->getLocation(), diag::err_flexible_array_not_at_end)
3896 << ivar->getDeclName() << IvarTy
3898 IsInvalidIvar =
true;
3900 if (RecordTy->getDecl()->hasFlexibleArrayMember()) {
3901 S.
Diag(ivar->getLocation(),
3902 diag::err_objc_variable_sized_type_not_at_end)
3903 << ivar->getDeclName() << IvarTy;
3904 IsInvalidIvar =
true;
3907 if (IsInvalidIvar) {
3908 S.
Diag(ivar->getNextIvar()->getLocation(),
3909 diag::note_next_ivar_declaration)
3910 << ivar->getNextIvar()->getSynthesize();
3911 ivar->setInvalidDecl();
3919 (Ivars.begin() == Ivars.end()) ?
nullptr : *Ivars.begin();
3922 while (SuperClass && SuperClass->
ivar_empty())
3926 std::advance(IvarIter, SuperClass->
ivar_size() - 1);
3930 diag::warn_superclass_variable_sized_type_not_at_end)
3945 const llvm::iterator_range<ObjCProtocolList::iterator> &Protocols) {
3946 for (
auto *PI : Protocols)
3957 for (
auto *MD : PDecl->
methods()) {
3958 if (!MD->isPropertyAccessor()) {
3959 if (
const auto *CMD =
3960 IDecl->getMethod(MD->getSelector(), MD->isInstanceMethod())) {
3961 if (CMD->isDirectMethod())
3962 DirectMembers.push_back(CMD);
3967 if (
const auto *CPD = IDecl->FindPropertyVisibleInPrimaryClass(
3968 PD->getIdentifier(),
3969 PD->isClassProperty()
3972 if (CPD->isDirectProperty())
3973 DirectMembers.push_back(CPD);
3976 if (!DirectMembers.empty()) {
3977 S.
Diag(CDecl->
getLocation(), diag::err_objc_direct_protocol_conformance)
3979 for (
const auto *MD : DirectMembers)
3980 S.
Diag(MD->getLocation(), diag::note_direct_member_here);
3995 assert(AtEnd.
isValid() &&
"Invalid location for '@end'");
3997 auto *OCD = cast<ObjCContainerDecl>(
CurContext);
3998 Decl *ClassDecl = OCD;
4000 bool isInterfaceDeclKind =
4001 isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl)
4002 || isa<ObjCProtocolDecl>(ClassDecl);
4003 bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
4009 if (
auto *OID = dyn_cast<ObjCImplementationDecl>(
CurContext)) {
4010 for (
auto *PropImpl : OID->property_impls()) {
4011 if (
auto *Getter = PropImpl->getGetterMethodDecl())
4012 if (Getter->isSynthesizedAccessorStub())
4013 OID->addDecl(Getter);
4014 if (
auto *Setter = PropImpl->getSetterMethodDecl())
4015 if (Setter->isSynthesizedAccessorStub())
4016 OID->addDecl(Setter);
4021 llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap;
4022 llvm::DenseMap<Selector, const ObjCMethodDecl*> ClsMap;
4024 for (
unsigned i = 0, e = allMethods.size(); i != e; i++ ) {
4026 cast_or_null<ObjCMethodDecl>(allMethods[i]);
4028 if (!Method)
continue;
4034 if ((isInterfaceDeclKind && PrevMethod && !
match)
4035 || (checkIdenticalMethods &&
match)) {
4058 if ((isInterfaceDeclKind && PrevMethod && !
match)
4059 || (checkIdenticalMethods &&
match)) {
4078 if (isa<ObjCInterfaceDecl>(ClassDecl)) {
4085 if (
C->IsClassExtension()) {
4093 if (CDecl->getIdentifier())
4097 for (
auto *I : CDecl->properties())
4099 CDecl->setAtEndRange(AtEnd);
4102 IC->setAtEndRange(AtEnd);
4109 for (
const auto *Ext : IDecl->visible_extensions()) {
4110 for (
const auto *
Property : Ext->instance_properties()) {
4113 = IC->FindPropertyImplDecl(
Property->getIdentifier(),
4115 if (PIDecl->getPropertyImplementation()
4119 for (
const auto *Ext : IDecl->visible_extensions()) {
4121 Ext->getInstanceMethod(
Property->getGetterName()))
4122 GetterMethod->setPropertyAccessor(
true);
4125 = Ext->getInstanceMethod(
Property->getSetterName()))
4126 SetterMethod->setPropertyAccessor(
true);
4134 if (IDecl->hasDesignatedInitializers())
4139 bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>();
4140 if (IDecl->getSuperClass() ==
nullptr) {
4143 if (!HasRootClassAttr) {
4146 Diag(DeclLoc, diag::warn_objc_root_class_missing)
4147 << IDecl->getIdentifier();
4155 Diag(SuperClassLoc, diag::note_objc_needs_superclass)
4158 Diag(SuperClassLoc, diag::note_objc_needs_superclass);
4161 }
else if (HasRootClassAttr) {
4163 Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass);
4171 if (IDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4172 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4173 Diag(IC->getLocation(), diag::err_restricted_superclass_mismatch);
4174 Diag(Super->getLocation(), diag::note_class_declared);
4178 if (IDecl->hasAttr<ObjCClassStubAttr>())
4179 Diag(IC->getLocation(), diag::err_implementation_of_class_stub);
4182 while (IDecl->getSuperClass()) {
4184 IDecl = IDecl->getSuperClass();
4190 dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
4191 CatImplClass->setAtEndRange(AtEnd);
4197 = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier())) {
4201 }
else if (
const auto *IntfDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
4203 if (!IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4204 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4205 Diag(IntfDecl->getLocation(), diag::err_restricted_superclass_mismatch);
4206 Diag(Super->getLocation(), diag::note_class_declared);
4210 if (IntfDecl->hasAttr<ObjCClassStubAttr>() &&
4211 !IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>())
4212 Diag(IntfDecl->getLocation(), diag::err_class_stub_subclassing_mismatch);
4215 if (isInterfaceDeclKind) {
4217 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4220 if (
VarDecl *VDecl = dyn_cast<VarDecl>(*I)) {
4221 if (!VDecl->hasExternalStorage())
4222 Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass);
4228 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4231 (*I)->setTopLevelDeclInObjCContainer();
4260 if (ResultObjectType->isObjCIdType() ||
4261 ResultObjectType->isObjCQualifiedIdType())
4266 = ResultObjectType->getInterfaceDecl()) {
4272 if (ResultClass->isSuperClassOf(CurrentClass))
4288class OverrideSearch {
4320 dyn_cast<ObjCCategoryDecl>(container)) {
4321 searchFromContainer(container);
4325 searchFromContainer(container);
4329 typedef decltype(Overridden)::iterator iterator;
4330 iterator begin()
const {
return Overridden.begin(); }
4331 iterator end()
const {
return Overridden.end(); }
4338#define OBJCCONTAINER(type, base) \
4340 searchFrom(cast<type##Decl>(container)); \
4342#define ABSTRACT_DECL(expansion)
4343#define DECL(type, base) \
4345#include "clang/AST/DeclNodes.inc"
4346 llvm_unreachable(
"not an ObjC container!");
4406 for (
const auto *Proto : protocols)
4418 Overridden.insert(meth);
4428 searchFromContainer(container);
4436 const auto *
attr = overridden->
getAttr<ObjCDirectAttr>();
4438 Diag(
attr->getLocation(), diag::note_previous_declaration);
4440 const auto *
attr = method->
getAttr<ObjCDirectAttr>();
4441 Diag(
attr->getLocation(), diag::err_objc_direct_on_override)
4452 auto IsMethodInCurrentClass = [CurrentClass](
const ObjCMethodDecl *M) {
4454 return M->getClassInterface()->getCanonicalDecl() ==
4458 OverrideSearch overrides(*
this, ObjCMethod);
4464 bool hasOverriddenMethodsInBaseOrProtocol =
false;
4466 if (!hasOverriddenMethodsInBaseOrProtocol) {
4467 if (isa<ObjCProtocolDecl>(overridden->getDeclContext()) ||
4468 !IsMethodInCurrentClass(overridden) || overridden->isOverriding()) {
4470 hasOverriddenMethodsInBaseOrProtocol =
true;
4484 unsigned CategCount = List.getBits();
4485 if (CategCount > 0) {
4488 if (CategCount > 1 ||
4489 !isa<ObjCCategoryImplDecl>(overridden->getDeclContext())) {
4490 OverrideSearch overrides(*
this, overridden);
4492 if (isa<ObjCProtocolDecl>(SuperOverridden->getDeclContext()) ||
4493 !IsMethodInCurrentClass(SuperOverridden)) {
4495 hasOverriddenMethodsInBaseOrProtocol =
true;
4496 overridden->setOverriding(
true);
4513 if (ObjCMethod->
isImplicit() && overridden->isImplicit())
4520 isa<ObjCProtocolDecl>(overridden->getDeclContext()));
4522 if (CurrentClass && overridden->
getDeclContext() != CurrentClass &&
4523 isa<ObjCInterfaceDecl>(overridden->getDeclContext()) &&
4528 PrevE = overridden->param_end();
4529 for (; ParamI != E && PrevI != PrevE; ++ParamI, ++PrevI) {
4530 assert(PrevI != overridden->param_end() &&
"Param mismatch");
4536 Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
4538 Diag(overridden->getLocation(), diag::note_previous_declaration);
4545 ObjCMethod->
setOverriding(hasOverriddenMethodsInBaseOrProtocol);
4555 bool prevUsesCSKeyword) {
4557 auto nullability =
type->getNullability();
4561 if (nullability.has_value() == prevNullability.has_value()) {
4567 if (*nullability == *prevNullability)
4571 S.
Diag(loc, diag::err_nullability_conflicting)
4594 if (prevMethod->
hasAttr<ObjCRequiresSuperAttr>() &&
4595 !method->
hasAttr<ObjCRequiresSuperAttr>()) {
4598 ObjCRequiresSuperAttr::CreateImplicit(S.
Context,
4615 unsigned numPrevParams = prevMethod->
param_size();
4616 for (
unsigned i = 0, n = std::min(numParams, numPrevParams); i != n; ++i) {
4636 llvm::Triple::x86 &&
4637 "x86-specific check invoked for a different target");
4641 if (
P->getType()->isVectorType()) {
4642 Loc =
P->getBeginLoc();
4658 VersionTuple AcceptedInVersion;
4659 if (Triple.getOS() == llvm::Triple::IOS)
4660 AcceptedInVersion = VersionTuple(9);
4661 else if (Triple.isMacOSX())
4662 AcceptedInVersion = VersionTuple(10, 11);
4668 SemaRef.
Diag(Loc, diag::err_objc_method_unsupported_param_ret_type)
4671 << (Triple.isMacOSX() ?
"macOS 10.11" :
"iOS 9");
4676 CD->
hasAttr<ObjCDirectMembersAttr>()) {
4687 bool diagnosed =
false;
4690 if (diagnosed || IMD->isImplicit())
4696 S.
Diag(IMD->getLocation(), diag::note_previous_declaration);
4714 if (
auto *IMD = IDecl->
getMethod(Sel, isInstance))
4717 if (Impl != ImpDecl)
4722 if (
auto *IMD = Cat->getMethod(Sel, isInstance))
4724 else if (
auto CatImpl = Cat->getImplementation())
4725 if (CatImpl != ImpDecl)
4726 if (
auto *IMD = Cat->getMethod(Sel, isInstance))
4739 bool isVariadic,
bool MethodDefinition) {
4742 Diag(MethodLoc, diag::err_missing_method_context);
4749 bool HasRelatedResultType =
false;
4757 QualType bareResultType = resultDeclType;
4762 Diag(MethodLoc, diag::warn_missing_method_return_type)
4768 MethodType == tok::minus, isVariadic,
4771 MethodDeclKind == tok::objc_optional
4774 HasRelatedResultType);
4778 for (
unsigned i = 0, e = Sel.
getNumArgs(); i != e; ++i) {
4782 if (!ArgInfo[i].
Type) {
4789 LookupResult R(*
this, ArgInfo[i].Name, ArgInfo[i].NameLoc,
4794 if (S->isDeclScope(PrevDecl)) {
4795 Diag(ArgInfo[i].NameLoc,
4796 (MethodDefinition ? diag::warn_method_param_redefinition
4797 : diag::warn_method_param_declaration))
4800 diag::note_previous_declaration);
4809 ArgInfo[i].NameLoc, ArgInfo[i].Name,
4822 if (Param->
hasAttr<BlocksAttr>()) {
4829 Params.push_back(Param);
4832 for (
unsigned i = 0, e = CNumArgs; i != e; ++i) {
4833 ParmVarDecl *Param = cast<ParmVarDecl>(CParamInfo[i].Param);
4842 Params.push_back(Param);
4855 if (
ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(ClassDecl)) {
4856 if (MethodType == tok::minus) {
4857 PrevMethod = ImpDecl->getInstanceMethod(Sel);
4858 ImpDecl->addInstanceMethod(ObjCMethod);
4860 PrevMethod = ImpDecl->getClassMethod(Sel);
4861 ImpDecl->addClassMethod(ObjCMethod);
4870 if (
auto *Setter = PropertyImpl->getSetterMethodDecl())
4871 if (Setter->getSelector() == Sel &&
4873 assert(Setter->isSynthesizedAccessorStub() &&
"autosynth stub expected");
4874 PropertyImpl->setSetterMethodDecl(ObjCMethod);
4876 if (
auto *Getter = PropertyImpl->getGetterMethodDecl())
4877 if (Getter->getSelector() == Sel &&
4879 assert(Getter->isSynthesizedAccessorStub() &&
"autosynth stub expected");
4880 PropertyImpl->setGetterMethodDecl(ObjCMethod);
4894 const auto *
attr = CanonicalMD->
getAttr<ObjCDirectAttr>();
4896 ObjCDirectAttr::CreateImplicit(
Context,
attr->getLocation()));
4903 if (
auto *IMD = IDecl->lookupMethod(ObjCMethod->
getSelector(),
4923 if (IDecl == IMD->getClassInterface()) {
4924 auto diagContainerMismatch = [&] {
4925 int decl = 0, impl = 0;
4927 if (
auto *Cat = dyn_cast<ObjCCategoryDecl>(IMD->getDeclContext()))
4928 decl = Cat->IsClassExtension() ? 1 : 2;
4930 if (isa<ObjCCategoryImplDecl>(ImpDecl))
4931 impl = 1 + (
decl != 0);
4934 diag::err_objc_direct_impl_decl_mismatch)
4936 Diag(IMD->getLocation(), diag::note_previous_declaration);
4940 const auto *
attr = ObjCMethod->
getAttr<ObjCDirectAttr>();
4942 diagContainerMismatch();
4943 }
else if (!IMD->isDirectMethod()) {
4944 Diag(
attr->getLocation(), diag::err_objc_direct_missing_on_decl);
4945 Diag(IMD->getLocation(), diag::note_previous_declaration);
4947 }
else if (IMD->isDirectMethod()) {
4948 const auto *
attr = IMD->getAttr<ObjCDirectAttr>();
4950 diagContainerMismatch();
4953 ObjCDirectAttr::CreateImplicit(
Context,
attr->getLocation()));
4959 if (isa<ObjCCategoryImplDecl>(ImpDecl) && IMD->isOverriding() &&
4972 for (
auto *
C : IDecl->visible_categories())
4973 for (
auto &
P :
C->protocols())
4974 if (
auto *IMD =
P->lookupMethod(ObjCMethod->
getSelector(),
4977 IMD->parameters().size() &&
4978 "Methods have different number of parameters");
4979 auto OI = IMD->param_begin(), OE = IMD->param_end();
4981 for (; OI != OE; ++OI, ++NI)
4986 if (!isa<ObjCProtocolDecl>(ClassDecl)) {
4991 IDecl = cast<ObjCCategoryDecl>(ClassDecl)->getClassInterface();
4999 cast<DeclContext>(ClassDecl)->addDecl(ObjCMethod);
5015 if (!CurrentClass) {
5017 CurrentClass = Cat->getClassInterface();
5018 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(ClassDecl))
5019 CurrentClass = Impl->getClassInterface();
5021 = dyn_cast<ObjCCategoryImplDecl>(ClassDecl))
5022 CurrentClass = CatImpl->getClassInterface();
5030 bool ARCError =
false;
5037 LangOpts.ObjCInferRelatedResultType) {
5038 bool InferRelatedResultType =
false;
5064 if (InferRelatedResultType &&
5069 if (MethodDefinition &&
5075 if (
const auto *
attr = ObjCMethod->
getAttr<AvailabilityAttr>()) {
5078 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
5080 ObjCMethod->
dropAttr<AvailabilityAttr>();
5103 Diag(D->
getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
5117 Diag(DeclStart, diag::err_undef_interface) << ClassName;
5121 Diag(DeclStart, diag::err_atdef_nonfragile_interface);
5129 for (
unsigned i = 0; i < Ivars.size(); i++) {
5135 ID->getIdentifier(), ID->getType(),
5137 Decls.push_back(FD);
5142 D != Decls.end(); ++D) {
5161 Diag(IdLoc, diag::err_arg_with_address_space);
5173 Diag(IdLoc, diag::err_illegal_qualifiers_on_catch_parm);
5178 Diag(IdLoc, diag::err_catch_param_not_objc_type);
5181 Diag(IdLoc, diag::err_catch_param_not_objc_type);
5214 diag::err_invalid_thread)
5248 if (New->
hasAttr<BlocksAttr>())
5261 Ivars.push_back(Iv);
5270 for (
unsigned I = 0, N = Sels.size(); I != N; ++I)
5281 Selector Sel = SelectorAndLocation.first;
5284 Diag(Loc, diag::warn_unimplemented_selector) << Sel;
5307 IV->getIdentifier());
5316 class UnusedBackingIvarChecker :
5323 bool InvokedSelfMethod;
5327 : S(S), Method(Method), IvarD(IvarD),
5328 AccessedIvar(
false), InvokedSelfMethod(
false) {
5334 AccessedIvar =
true;
5343 InvokedSelfMethod =
true;
5352 if (S->hasUnrecoverableErrorOccurred())
5356 unsigned DIAG = diag::warn_unused_property_backing_ivar;
5366 if (CurMethod->isSynthesizedAccessorStub())
5369 UnusedBackingIvarChecker Checker(*
this, CurMethod, IV);
5370 Checker.TraverseStmt(CurMethod->getBody());
5371 if (Checker.AccessedIvar)
5378 if (!IV->
isReferenced() || !Checker.InvokedSelfMethod) {
Defines the clang::ASTContext interface.
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY)
static QualType getObjectType(APValue::LValueBase B)
Retrieves the "underlying object type" of the given expression, as used by __builtin_object_size.
llvm::MachO::Record Record
static bool IsVariableSizedType(QualType T)
static void DiagnoseVariableSizedIvars(Sema &S, ObjCContainerDecl *OCD)
static bool HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param)
HasExplicitOwnershipAttr - returns true when pointer to ObjC pointer has explicit ownership attribute...
static void checkObjCDirectMethodClashes(Sema &S, ObjCInterfaceDecl *IDecl, ObjCMethodDecl *Method, ObjCImplDecl *ImpDecl=nullptr)
static bool CheckMethodOverrideParam(Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, ParmVarDecl *ImplVar, ParmVarDecl *IfaceVar, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn)
static SourceRange getTypeRange(TypeSourceInfo *TSI)
std::unique_ptr< ProtocolNameSet > LazyProtocolNameSet
static bool CheckMethodOverrideReturn(Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn)
static void DiagnoseCategoryDirectMembersProtocolConformance(Sema &S, ObjCProtocolDecl *PDecl, ObjCCategoryDecl *CDecl)
static bool checkTypeParamListConsistency(Sema &S, ObjCTypeParamList *prevTypeParams, ObjCTypeParamList *newTypeParams, TypeParamListContext newContext)
Check consistency between two Objective-C type parameter lists, e.g., between a category/extension an...
static bool tryMatchRecordTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, const Type *left, const Type *right)
static void HelperSelectorsForTypoCorrection(SmallVectorImpl< const ObjCMethodDecl * > &BestMethod, StringRef Typo, const ObjCMethodDecl *Method)
static bool objcModifiersConflict(Decl::ObjCDeclQualifier x, Decl::ObjCDeclQualifier y)
Determine whether two set of Objective-C declaration qualifiers conflict.
static bool shouldWarnUndefinedMethod(const ObjCMethodDecl *M)
static bool FilterMethodsByTypeBound(ObjCMethodDecl *Method, const ObjCObjectType *TypeBound)
Return true if the given method is wthin the type bound.
static void DiagnoseObjCImplementedDeprecations(Sema &S, const NamedDecl *ND, SourceLocation ImplLoc)
static void findProtocolsWithExplicitImpls(const ObjCProtocolDecl *PDecl, ProtocolNameSet &PNS)
static bool matchTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, QualType leftQT, QualType rightQT)
static void DiagnoseRetainableFlexibleArrayMember(Sema &S, ObjCInterfaceDecl *ID)
Diagnose attempts to use flexible array member with retainable object type.
static void mergeInterfaceMethodToImpl(Sema &S, ObjCMethodDecl *method, ObjCMethodDecl *prevMethod)
Merge information from the declaration of a method in the @interface (or a category/extension) into t...
static bool HelperIsMethodInObjCType(Sema &S, Selector Sel, QualType ObjectType)
static void CheckProtocolMethodDefs(Sema &S, ObjCImplDecl *Impl, ObjCProtocolDecl *PDecl, bool &IncompleteImpl, const Sema::SelectorSet &InsMap, const Sema::SelectorSet &ClsMap, ObjCContainerDecl *CDecl, LazyProtocolNameSet &ProtocolsExplictImpl)
CheckProtocolMethodDefs - This routine checks unimplemented methods Declared in protocol,...
static void WarnUndefinedMethod(Sema &S, ObjCImplDecl *Impl, ObjCMethodDecl *method, bool &IncompleteImpl, unsigned DiagID, NamedDecl *NeededFor=nullptr)
static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl, ObjCProtocolDecl *&UndefinedProtocol)
static bool isObjCTypeSubstitutable(ASTContext &Context, const ObjCObjectPointerType *A, const ObjCObjectPointerType *B, bool rejectId)
Determines if type B can be substituted for type A.
llvm::DenseSet< IdentifierInfo * > ProtocolNameSet
FIXME: Type hierarchies in Objective-C can be deep.
static QualType mergeTypeNullabilityForRedecl(Sema &S, SourceLocation loc, QualType type, bool usesCSKeyword, SourceLocation prevLoc, QualType prevType, bool prevUsesCSKeyword)
Merge type nullability from for a redeclaration of the same entity, producing the updated type of the...
static bool diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, Sema &S)
Issue a warning if the parameter of the overridden method is non-escaping but the parameter of the ov...
static bool isAcceptableMethodMismatch(ObjCMethodDecl *chosen, ObjCMethodDecl *other)
Determines if this is an "acceptable" loose mismatch in the global method pool.
static void mergeObjCDirectMembers(Sema &S, Decl *CD, ObjCMethodDecl *Method)
static void DiagnoseWeakIvars(Sema &S, ObjCImplementationDecl *ID)
Diagnose attempts to define ARC-__weak ivars when __weak is disabled.
static void checkObjCMethodX86VectorTypes(Sema &SemaRef, const ObjCMethodDecl *Method)
Verify that the method parameters/return value have types that are supported by the x86 target.
static bool checkMethodFamilyMismatch(Sema &S, ObjCMethodDecl *impl, ObjCMethodDecl *decl)
In ARC, check whether the conventional meanings of the two methods match.
static bool isMethodContextSameForKindofLookup(ObjCMethodDecl *Method, ObjCMethodDecl *MethodInList)
static Sema::ResultTypeCompatibilityKind CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method, ObjCInterfaceDecl *CurrentClass)
Check whether the declared result type of the given Objective-C method declaration is compatible with...
static Decl::ObjCDeclQualifier CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal)
CvtQTToAstBitMask - utility routine to produce an AST bitmask for objective-c's type qualifier from t...
static void diagnoseUseOfProtocols(Sema &TheSema, ObjCContainerDecl *CD, ObjCProtocolDecl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs)
Defines the SourceManager interface.
__DEVICE__ long long abs(long long __n)
virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D)
Handle the specified top-level declaration that occurred inside and ObjC container.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
bool AnyObjCImplementation()
Return true if there is at least one @implementation in the TU.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
bool ObjCQualifiedIdTypesAreCompatible(const ObjCObjectPointerType *LHS, const ObjCObjectPointerType *RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
SelectorTable & Selectors
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized,...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const clang::PrintingPolicy & getPrintingPolicy() const
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
const TargetInfo & getTargetInfo() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT, bool IsParam) const
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
CollectInheritedProtocols - Collect all protocols in current class and those inherited by it.
The result of parsing/analyzing an expression, statement etc.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
Type source information for an attributed type.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
static std::optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
SourceRange getRange() const
bool isSet() const
Deprecated.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isObjCContainer() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDecl(Decl *D)
Add the declaration D into this context.
Decl::Kind getDeclKind() const
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
Captures information about "declaration specifiers".
static const TST TST_typename
void ClearStorageClassSpecs()
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
void SetRangeEnd(SourceLocation Loc)
void SetRangeStart(SourceLocation Loc)
SCS
storage-class-specifier
TSCS getThreadStorageClassSpec() const
bool isInlineSpecified() const
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getInlineSpecLoc() const
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
void setTopLevelDeclInObjCContainer(bool V=true)
bool isReferenced() const
Whether any declaration of this entity was referenced.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
bool isInvalidDecl() const
SourceLocation getLocation() const
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
void setImplicit(bool I=true)
DeclContext * getDeclContext()
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
void setLexicalDeclContext(DeclContext *DC)
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
SourceLocation getIdentifierLoc() const
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
const IdentifierInfo * getIdentifier() const
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
unsigned getBitWidthValue(const ASTContext &Ctx) const
Computes the bit width of this field, if this is a bit field.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
One of these records is kept for each identifier that is lexed.
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
clang::ObjCRuntime ObjCRuntime
Represents the results of name lookup.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
ObjCCategoryDecl - Represents a category declaration.
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, const IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCCategoryImplDecl * getImplementation() const
ObjCInterfaceDecl * getClassInterface()
bool IsClassExtension() const
const ObjCProtocolList & getReferencedProtocols() const
void setImplementation(ObjCCategoryImplDecl *ImplD)
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCCategoryDecl * getCategoryDecl() const
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, const IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
ObjCCompatibleAliasDecl - Represents alias of a class.
static ObjCCompatibleAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *aliasedClass)
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
method_range methods() const
SourceRange getAtEndRange() const
instmeth_range instance_methods() const
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
void setAtEndRange(SourceRange atEnd)
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
prop_range properties() const
classmeth_range class_methods() const
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
Captures information about "declaration specifiers" specific to Objective-C.
ObjCDeclQualifier
ObjCDeclQualifier - Qualifier used on types in method declarations.
ObjCDeclQualifier getObjCDeclQualifier() const
propimpl_range property_impls() const
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
const ObjCInterfaceDecl * getSuperClass() const
Represents an ObjC class declaration.
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
ivar_iterator ivar_end() const
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, const IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
unsigned ivar_size() const
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
bool hasDefinition() const
Determine whether this class has been defined.
all_protocol_range all_referenced_protocols() const
visible_extensions_range visible_extensions() const
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
ObjCCategoryDecl * FindCategoryDeclaration(const IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
ivar_iterator ivar_begin() const
void setImplementation(ObjCImplementationDecl *ImplD)
known_categories_range known_categories() const
void setSuperClass(TypeSourceInfo *superClass)
const ObjCProtocolList & getReferencedProtocols() const
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class,...
ObjCImplementationDecl * getImplementation() const
void setEndOfDefinitionLoc(SourceLocation LE)
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
visible_categories_range visible_categories() const
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
ObjCInterfaceDecl * getSuperClass() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
Interfaces are the core concept in Objective-C for object oriented design.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCIvarDecl * getNextIvar()
ObjCIvarRefExpr - A reference to an ObjC instance variable.
ObjCList - This is a simple template class used to hold various lists of decls etc,...
void set(T *const *InList, unsigned Elts, ASTContext &Ctx)
An expression that sends a message to the given Objective-C object or class.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
@ Instance
The receiver is an object instance.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
ObjCMethodDecl - Represents an instance or class method declaration.
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface.
ImplicitParamDecl * getSelfDecl() const
void setObjCDeclQualifier(ObjCDeclQualifier QV)
void setDefined(bool isDefined)
ObjCDeclQualifier getObjCDeclQualifier() const
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
bool isPropertyAccessor() const
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isSynthesizedAccessorStub=false, bool isImplicitlyDeclared=false, bool isDefined=false, ObjCImplementationControl impControl=ObjCImplementationControl::None, bool HasRelatedResultType=false)
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
param_const_iterator param_end() const
param_const_iterator param_begin() const
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
void setRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
bool isSynthesizedAccessorStub() const
SourceLocation getSelectorLoc(unsigned Index) const
SourceRange getReturnTypeSourceRange() const
void setOverriding(bool IsOver)
const ParmVarDecl *const * param_const_iterator
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
SourceLocation getBeginLoc() const LLVM_READONLY
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=std::nullopt)
Sets the method's parameters and selector source locations.
bool isDirectMethod() const
True if the method is tagged as objc_direct.
Selector getSelector() const
ImplicitParamDecl * getCmdDecl() const
bool isInstanceMethod() const
void setReturnType(QualType T)
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implicit parameters.
QualType getReturnType() const
ParmVarDecl *const * param_iterator
ObjCImplementationControl getImplementationControl() const
bool isClassMethod() const
ObjCInterfaceDecl * getClassInterface()
Wraps an ObjCPointerType with source location information.
void setStarLoc(SourceLocation Loc)
Represents a pointer to an Objective C object.
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
Represents a class type in Objective C.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
Represents one property declaration in an Objective-C interface.
ObjCIvarDecl * getPropertyIvarDecl() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Represents an Objective-C protocol declaration.
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
bool hasDefinition() const
Determine whether this protocol has a definition.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
const ObjCProtocolList & getReferencedProtocols() const
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
void startDefinition()
Starts the definition of this Objective-C protocol.
protocol_range protocols() const
A list of Objective-C protocols, along with the source locations at which they were referenced.
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
Represents the declaration of an Objective-C type parameter.
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
void setVariance(ObjCTypeParamVariance variance)
Set the variance of this type parameter.
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
SourceRange getSourceRange() const
unsigned size() const
Determine the number of type parameters in this list.
ObjCTypeParamDecl * back() const
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
SourceLocation getLAngleLoc() const
Represents a parameter to a function.
void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
ObjCDeclQualifier getObjCDeclQualifier() const
void setObjCMethodScopeInfo(unsigned parameterIndex)
static const ParsedAttributesView & none()
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
The collection of all-type qualifiers we support.
void removeCVRQualifiers(unsigned mask)
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
std::string getAsString() const
Represents a struct/union/class.
field_iterator field_end() const
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Base for LValueReferenceType and RValueReferenceType.
Scope - A scope is a transient data structure that is used while parsing the program.
Selector getSelector(unsigned NumArgs, const IdentifierInfo **IIV)
Can create any sort of selector.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
std::string getAsString() const
Derive the full selector name (e.g.
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
bool isUnarySelector() const
unsigned getNumArgs() const
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
llvm::DenseMap< Selector, Lists >::iterator iterator
iterator find(Selector Sel)
std::pair< ObjCMethodList, ObjCMethodList > Lists
std::pair< iterator, bool > insert(std::pair< Selector, Lists > &&Val)
Sema - This implements semantic analysis and AST building for C.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl * > &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
void ActOnObjCContainerStartDefinition(ObjCContainerDecl *IDecl)
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method,...
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
void ActOnStartOfObjCMethodDef(Scope *S, Decl *D)
ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible and user declared,...
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl * > Decls)
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
@ LookupAnyName
Look up any declaration with any name.
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function.
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList * > TypeParamLists, unsigned NumElts)
void CheckConflictingOverridingMethod(ObjCMethodDecl *Method, ObjCMethodDecl *Overridden, bool IsProtocolMethodDecl)
@ OCK_CategoryImplementation
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
ObjCTypeParamList * actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef< Decl * > typeParams, SourceLocation rAngleLoc)
void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP)
CheckCategoryVsClassMethodMatches - Checks that methods implemented in category matches with those im...
void ActOnTypedefedProtocols(SmallVectorImpl< Decl * > &ProtocolRefs, SmallVectorImpl< SourceLocation > &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc)
ActOnTypedefedProtocols - this action finds protocol list as part of the typedef'ed use for a qualifi...
ObjCCategoryImplDecl * ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, const IdentifierInfo *CatName, SourceLocation CatLoc, const ParsedAttributesView &AttrList)
ActOnStartCategoryImplementation - Perform semantic checks on the category implementation declaration...
void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
WarnExactTypedMethods - This routine issues a warning if method implementation declaration matches ex...
ObjCImplementationDecl * ActOnStartClassImplementation(SourceLocation AtClassImplLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, const IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc, const ParsedAttributesView &AttrList)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods=std::nullopt, ArrayRef< DeclGroupPtrTy > allTUVars=std::nullopt)
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
Decl * ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc, IdentifierInfo *AliasName, SourceLocation AliasLocation, IdentifierInfo *ClassName, SourceLocation ClassLocation)
ActOnCompatibilityAlias - this action is called after complete parsing of a @compatibility_alias decl...
void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD)
DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which backs the property is n...
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Find the protocol with the given name, if any.
void ActOnSuperClassOfClassInterface(Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ASTContext & getASTContext() const
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall)
Check whether the given method, which must be in the 'init' family, is a valid member of that family.
void MatchAllMethodDeclarations(const SelectorSet &InsMap, const SelectorSet &ClsMap, SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool &IncompleteImpl, bool ImmediateClass, bool WarnCategoryMethodImpl=false)
MatchAllMethodDeclarations - Check methods declaraed in interface or or protocol against those declar...
void CheckObjCMethodDirectOverrides(ObjCMethodDecl *method, ObjCMethodDecl *overridden)
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
void PushFunctionScope()
Enter a new function scope.
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
ObjCInterfaceDecl * getObjCInterfaceDecl(const IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, const IdentifierInfo *ClassName, SmallVectorImpl< Decl * > &Decls)
Called whenever @defs(ClassName) is encountered in the source.
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId, SourceLocation ProtocolLoc, IdentifierInfo *TypeArgId, SourceLocation TypeArgLoc, bool SelectProtocolFirst=false)
ObjCProtocolDecl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
void updateOutOfDateSelector(Selector Sel)
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
const LangOptions & LangOpts
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
const ObjCMethodDecl * SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType())
DeclContext * getCurLexicalContext() const
sema::FunctionScopeInfo * getCurFunction() const
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Decl * ActOnMethodDeclaration(Scope *S, SourceLocation BeginLoc, SourceLocation EndLoc, tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, ArrayRef< SourceLocation > SelectorLocs, Selector Sel, ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
bool CollectMultipleMethodsInGlobalPool(Selector Sel, SmallVectorImpl< ObjCMethodDecl * > &Methods, bool InstanceFirst, bool CheckTheOther, const ObjCObjectType *TypeBound=nullptr)
We first select the type of the method: Instance or Factory, then collect all methods with that type.
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass, SmallVectorImpl< ObjCMethodDecl * > &Methods)
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, const IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
void applyFunctionAttributesBeforeParsingBody(Decl *FD)
ObjCMethodDecl * LookupImplementedMethodInGlobalPool(Selector Sel)
LookupImplementedMethodInGlobalPool - Returns the method which has an implementation.
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine if D has a visible definition.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
void ActOnObjCContainerFinishDefinition()
SourceManager & getSourceManager() const
ObjCCategoryDecl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, const IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, ObjCInterfaceDecl *ID)
DiagnoseClassExtensionDupMethods - Check for duplicate declaration of a class method in its extension...
void WarnConflictingTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
TypeResult ActOnTypeName(Declarator &D)
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
ExternalSemaSource * getExternalSource() const
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
CheckParmsForFunctionDef - Check that the parameters of the given function are appropriate for the de...
void ProcessPropertyDecl(ObjCPropertyDecl *property)
Process the specified property declaration and create decls for the setters and getters as needed.
RedeclarationKind forRedeclarationInCurContext() const
ObjCInterfaceDecl * ActOnStartClassInterface(Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
void actOnObjCTypeArgsOrProtocolQualifiers(Scope *S, ParsedType baseType, SourceLocation lAngleLoc, ArrayRef< IdentifierInfo * > identifiers, ArrayRef< SourceLocation > identifierLocs, SourceLocation rAngleLoc, SourceLocation &typeArgsLAngleLoc, SmallVectorImpl< ParsedType > &typeArgs, SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc, SmallVectorImpl< Decl * > &protocols, SourceLocation &protocolRAngleLoc, bool warnOnIncompleteProtocols)
Given a list of identifiers (and their locations), resolve the names to either Objective-C protocol q...
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, const ObjCMethodDecl *PrevMethod, MethodMatchStrategy strategy=MMS_strict)
MatchTwoMethodDeclarations - Checks if two methods' type match and returns true, or false,...
ObjCIvarDecl * GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, const ObjCPropertyDecl *&PDecl) const
GetIvarBackingPropertyAccessor - If method is a property setter/getter and it property has a backing ...
void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool IncompleteImpl=false)
ImplMethodsVsClassMethods - This is main routine to warn if any method remains unimplemented in the c...
bool inferObjCARCLifetime(ValueDecl *decl)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
void DiagnoseUseOfUnimplementedSelectors()
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ResultTypeCompatibilityKind
Describes the compatibility of a result type with its method.
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
DiagnosticsEngine & Diags
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, const ParsedAttributesView &attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
DiagnoseDuplicateIvars - Check for duplicate ivars in the entire class at the start of @implementatio...
bool CheckObjCDeclScope(Decl *D)
Checks that the Objective-C declaration is declared in the global scope.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
llvm::BumpPtrAllocator BumpAlloc
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
Decl * ActOnObjCExceptionDecl(Scope *S, Declarator &D)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
bool CheckForwardProtocolDeclarationForCircularDependency(IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, const ObjCList< ObjCProtocolDecl > &PList)
IdentifierResolver IdResolver
llvm::SmallVector< std::pair< SourceLocation, const BlockDecl * >, 1 > ImplicitlyRetainedSelfLocs
List of SourceLocations where 'self' is implicitly retained inside a block.
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, ArrayRef< IdentifierLocPair > ProtocolId, SmallVectorImpl< Decl * > &Protocols)
FindProtocolDeclaration - This routine looks up protocols and issues an error if they are not declare...
ObjCContainerKind getObjCContainerKind() const
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
void DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl< ObjCMethodDecl * > &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
SourceLocation getBeginLoc() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled.
Represents a declaration of a type.
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isIncompleteArrayType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
bool isScalarType() const
bool isObjCQualifiedIdType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
bool isObjCIdType() const
bool isObjCObjectType() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
bool isVectorType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
bool isObjCIndependentClassType() const
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
Simple class containing the result of Sema::CorrectTypo.
DeclClass * getCorrectionDeclAs() const
void setType(QualType newType)
Represents a variable declaration or definition.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
void setExceptionVariable(bool EV)
bool ObjCIsDesignatedInit
True when this is a method marked as a designated initializer.
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super's implementation, such as -dealloc,...
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
bool ObjCIsSecondaryInit
True when this is an initializer method not marked as a designated initializer within a class that ha...
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
ObjCMethodFamily
A family of Objective-C methods.
@ OMF_None
No particular method family.
@ Property
The type of a property.
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
@ Class
The "class" keyword.
AvailabilityResult
Captures the result of checking the availability of a declaration.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
@ Invariant
The parameter is invariant: must match exactly.
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc, SourceLocation UnalignedQualLoc)
Return a DeclaratorChunk for a pointer.
a linked list of methods with the same selector name but different signatures.
ObjCMethodDecl * getMethod() const
void setMethod(ObjCMethodDecl *M)
void setNext(ObjCMethodList *L)
bool hasMoreThanOneDecl() const
ObjCMethodList * getNext() const