28 #include "llvm/ADT/DenseMap.h" 29 #include "llvm/ADT/DenseSet.h" 31 using namespace clang;
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.endswith(
"_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");
376 diag::err_func_def_incomplete_result))
398 if (!Param->isInvalidDecl() &&
401 Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
404 if (Param->getIdentifier())
447 ImplDeclOfMethodDecl = OID->getImplementation();
448 else if (
ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContDeclOfMethodDecl)) {
449 if (CD->IsClassExtension()) {
451 ImplDeclOfMethodDecl = OID->getImplementation();
453 ImplDeclOfMethodDecl = CD->getImplementation();
457 if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
465 IC->getSuperClass() !=
nullptr;
466 }
else if (IC->hasDesignatedInitializers()) {
492 (SuperMethod && SuperMethod->
hasAttr<ObjCRequiresSuperAttr>());
505 ObjCInterfaceValidatorCCC() : CurrentIDecl(
nullptr) {}
507 : CurrentIDecl(IDecl) {}
509 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
523 unsigned NumProtoRefs,
528 for (
unsigned i = 0; i < NumProtoRefs; ++i) {
556 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(IDecl),
559 << SuperName << ClassName);
565 Diag(SuperLoc, diag::err_recursive_superclass)
566 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
570 dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
574 if (SuperClassDecl) {
579 if (PrevDecl && !SuperClassDecl) {
583 dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
584 QualType T = TDecl->getUnderlyingType();
604 if (!SuperClassDecl) {
605 Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
610 if (!dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
612 Diag(SuperLoc, diag::err_undef_superclass)
613 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
616 diag::err_forward_superclass,
619 SourceRange(AtInterfaceLoc, ClassLoc))) {
620 SuperClassDecl =
nullptr;
625 if (SuperClassType.isNull()) {
626 assert(!SuperClassDecl &&
"Failed to set SuperClassType?");
632 if (!SuperTypeArgs.empty()) {
640 SuperTypeArgsRange.
getEnd(),
652 if (!SuperClassTInfo) {
672 if (parsedTypeBound) {
683 diag::err_objc_type_param_bound_missing_pointer)
684 << typeBound << paramName
703 diag::err_objc_type_param_bound_nonobject)
704 << typeBound << paramName;
707 typeBoundInfo =
nullptr;
716 bool diagnosed =
false;
720 rangeToRemove = attr.getLocalSourceRange();
721 if (attr.getTypePtr()->getImmediateNullability()) {
722 Diag(attr.getBeginLoc(),
723 diag::err_objc_type_param_bound_explicit_nullability)
724 << paramName << typeBound
734 diag::err_objc_type_param_bound_qualified)
735 << paramName << typeBound
745 if (!quals.
empty()) {
755 if (!typeBoundInfo) {
762 index, paramLoc, paramName, colonLoc,
773 reinterpret_cast<ObjCTypeParamDecl * const *>(typeParamsIn.data()),
774 typeParamsIn.size());
780 llvm::SmallDenseMap<IdentifierInfo *, ObjCTypeParamDecl *> knownParams;
781 for (
auto typeParam : typeParams) {
782 auto known = knownParams.find(typeParam->getIdentifier());
783 if (known != knownParams.end()) {
784 Diag(typeParam->getLocation(), diag::err_objc_type_param_redecl)
785 << typeParam->getIdentifier()
788 typeParam->setInvalidDecl();
790 knownParams.insert(std::make_pair(typeParam->getIdentifier(), typeParam));
802 for (
auto typeParam : *typeParamList) {
803 if (!typeParam->isInvalidDecl()) {
829 if (prevTypeParams->
size() != newTypeParams->
size()) {
831 if (newTypeParams->
size() > prevTypeParams->
size()) {
837 S.
Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
838 <<
static_cast<unsigned>(newContext)
839 << (newTypeParams->
size() > prevTypeParams->
size())
840 << prevTypeParams->
size()
841 << newTypeParams->
size();
847 for (
unsigned i = 0, n = prevTypeParams->
size(); i != n; ++i) {
854 newContext != TypeParamListContext::Definition) {
873 auto diag = S.
Diag(diagLoc,
874 diag::err_objc_type_param_variance_conflict)
875 <<
static_cast<unsigned>(newTypeParam->
getVariance())
877 <<
static_cast<unsigned>(prevTypeParam->
getVariance())
886 StringRef newVarianceStr
893 (newVarianceStr +
" ").
str());
920 S.
Diag(newBoundRange.
getBegin(), diag::err_objc_type_param_bound_conflict)
945 if (newContext == TypeParamListContext::ForwardDeclaration ||
946 newContext == TypeParamListContext::Definition) {
954 diag::err_objc_type_param_bound_missing)
957 << (newContext == TypeParamListContext::ForwardDeclaration)
977 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
980 assert(ClassName &&
"Missing class identifier");
987 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
988 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
995 if (PrevIDecl && PrevIDecl->getIdentifier() != ClassName) {
1008 ClassName = PrevIDecl->getIdentifier();
1015 if (typeParamList) {
1019 TypeParamListContext::Definition)) {
1020 typeParamList =
nullptr;
1023 Diag(ClassLoc, diag::err_objc_parameterized_forward_class_first)
1025 Diag(prevTypeParamList->getLAngleLoc(), diag::note_previous_decl)
1030 for (
auto typeParam : *prevTypeParamList) {
1031 clonedTypeParams.push_back(
1035 typeParam->getVariance(),
1037 typeParam->getIndex(),
1039 typeParam->getIdentifier(),
1054 typeParamList, PrevIDecl, ClassLoc);
1058 Diag(AtInterfaceLoc, diag::err_duplicate_class_def)
1059 << PrevIDecl->getDeclName();
1060 Diag(Def->getLocation(), diag::note_previous_definition);
1079 ClassName, ClassLoc,
1080 SuperName, SuperLoc, SuperTypeArgs,
1081 SuperTypeArgsRange);
1089 NumProtoRefs, ProtoLocs);
1113 if (
const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) {
1114 QualType T = TDecl->getUnderlyingType();
1117 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end());
1122 ProtocolLocs.append(OPT->getNumProtocols(), SuperLoc);
1139 Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
1148 dyn_cast_or_null<TypedefNameDecl>(CDeclU)) {
1149 QualType T = TDecl->getUnderlyingType();
1152 ClassName = IDecl->getIdentifier();
1161 Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
1184 E = PList.
end(); I != E; ++I) {
1187 if (PDecl->getIdentifier() == PName) {
1188 Diag(Ploc, diag::err_protocol_has_circular_dependency);
1189 Diag(PrevLoc, diag::note_previous_definition);
1193 if (!PDecl->hasDefinition())
1197 PDecl->getLocation(), PDecl->getReferencedProtocols()))
1211 assert(ProtocolName &&
"Missing protocol identifier");
1217 Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName;
1218 Diag(Def->getLocation(), diag::note_previous_definition);
1225 ProtocolLoc, AtProtoInterfaceLoc,
1232 PDecl->startDefinition();
1240 ProtocolName, ProtocolLoc, PrevDecl->
getLocation(), PList);
1245 ProtocolLoc, AtProtoInterfaceLoc,
1249 PDecl->startDefinition();
1259 if (!err && NumProtoRefs ) {
1262 NumProtoRefs, ProtoLocs);
1274 UndefinedProtocol = PDecl;
1280 UndefinedProtocol = PI;
1307 Diag(Pair.second, diag::err_undeclared_protocol) << Pair.first;
1316 if (!ForObjCContainer) {
1325 if (WarnOnDeclarations &&
1327 Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first;
1328 Diag(UndefinedProtocol->
getLocation(), diag::note_protocol_decl_undefined)
1329 << UndefinedProtocol;
1331 Protocols.push_back(PDecl);
1342 ObjCTypeArgOrProtocolValidatorCCC(
ASTContext &context,
1344 :
Context(context), LookupKind(lookupKind) { }
1346 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
1360 if (isa<RecordDecl>(typeDecl) && !Context.
getLangOpts().CPlusPlus)
1366 if (
type->isObjCObjectPointerType() ||
1367 type->isBlockPointerType() ||
1368 type->isDependentType() ||
1369 type->isObjCObjectType())
1392 bool SelectProtocolFirst) {
1393 Diag(TypeArgLoc, diag::err_objc_type_args_and_protocols)
1394 << SelectProtocolFirst << TypeArgId << ProtocolId
1411 bool warnOnIncompleteProtocols) {
1414 unsigned numProtocolsResolved = 0;
1415 auto resolvedAsProtocols = [&] {
1416 assert(numProtocolsResolved == identifiers.size() &&
"Unresolved protocols");
1423 bool allAreTypeNames =
false;
1427 baseClass = objcObjectType->getInterface();
1429 if (
auto typeParams = baseClass->getTypeParamList()) {
1430 if (typeParams->size() == numProtocolsResolved) {
1432 allAreTypeNames =
true;
1439 for (
unsigned i = 0, n = protocols.size(); i != n; ++i) {
1444 if (!warnOnIncompleteProtocols) {
1456 if (warnOnIncompleteProtocols &&
1458 Diag(identifierLocs[i], diag::warn_undef_protocolref)
1467 if (allAreTypeNames) {
1470 if (isa<ObjCInterfaceDecl>(
decl)) {
1472 firstClassNameLoc = identifierLocs[i];
1473 }
else if (!isa<TypeDecl>(
decl)) {
1475 allAreTypeNames =
false;
1478 allAreTypeNames =
false;
1487 if (allAreTypeNames && firstClassNameLoc.
isValid()) {
1488 llvm::SmallPtrSet<ObjCProtocolDecl*, 8> knownProtocols;
1490 bool allProtocolsDeclared =
true;
1491 for (
auto proto : protocols) {
1492 if (knownProtocols.count(static_cast<ObjCProtocolDecl *>(proto)) == 0) {
1493 allProtocolsDeclared =
false;
1498 if (allProtocolsDeclared) {
1499 Diag(firstClassNameLoc, diag::warn_objc_redundant_qualified_class_type)
1500 << baseClass->getDeclName() <<
SourceRange(lAngleLoc, rAngleLoc)
1506 protocolLAngleLoc = lAngleLoc;
1507 protocolRAngleLoc = rAngleLoc;
1508 assert(protocols.size() == identifierLocs.size());
1512 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1514 protocols.push_back(proto);
1516 ++numProtocolsResolved;
1520 if (numProtocolsResolved == identifiers.size())
1521 return resolvedAsProtocols();
1527 typedef llvm::PointerUnion<TypeDecl *, ObjCInterfaceDecl *> TypeOrClassDecl;
1529 unsigned numTypeDeclsResolved = 0;
1530 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1534 typeDecls.push_back(TypeOrClassDecl());
1538 if (
auto typeDecl = dyn_cast<TypeDecl>(decl)) {
1539 typeDecls.push_back(typeDecl);
1540 ++numTypeDeclsResolved;
1544 if (
auto objcClass = dyn_cast<ObjCInterfaceDecl>(decl)) {
1545 typeDecls.push_back(objcClass);
1546 ++numTypeDeclsResolved;
1550 typeDecls.push_back(TypeOrClassDecl());
1557 auto resolveTypeReference = [&](TypeOrClassDecl typeDecl,
SourceLocation loc)
1561 const char* prevSpec;
1564 if (
auto *actualTypeDecl = typeDecl.dyn_cast<
TypeDecl *>())
1592 Diag(loc, diag::err_objc_type_arg_missing_star)
1603 auto resolvedAsTypeDecls = [&] {
1607 assert(numTypeDeclsResolved == identifiers.size() &&
"Unresolved type decl");
1609 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1611 TypeResult type = resolveTypeReference(typeDecls[i], identifierLocs[i]);
1617 typeArgs.push_back(type.
get());
1620 typeArgsLAngleLoc = lAngleLoc;
1621 typeArgsRAngleLoc = rAngleLoc;
1626 if (numTypeDeclsResolved == identifiers.size())
1627 return resolvedAsTypeDecls();
1633 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1636 if (protocols[i] || typeDecls[i]) {
1642 if (protocols[i] && typeDecls[i])
1665 identifiers[i], identifierLocs[i],
1666 protocols[i] !=
nullptr);
1677 llvm::make_unique<ObjCTypeArgOrProtocolValidatorCCC>(
Context,
1684 PDiag(diag::err_undeclared_protocol_suggest)
1687 protocols[i] = proto;
1688 ++numProtocolsResolved;
1695 PDiag(diag::err_unknown_typename_suggest)
1698 typeDecls[i] = typeDecl;
1699 ++numTypeDeclsResolved;
1706 PDiag(diag::err_unknown_type_or_class_name_suggest)
1707 << identifiers[i] <<
true);
1709 typeDecls[i] = objcClass;
1710 ++numTypeDeclsResolved;
1716 Diag(identifierLocs[i],
1717 (lookupKind ==
LookupAnyName ? diag::err_objc_type_arg_missing
1719 : diag::err_unknown_typename))
1728 if (numProtocolsResolved == identifiers.size())
1729 return resolvedAsProtocols();
1732 assert(numTypeDeclsResolved == identifiers.size() &&
"Not all types?");
1733 return resolvedAsTypeDecls();
1744 llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
1745 for (
auto *MD : ID->
methods())
1746 MethodMap[MD->getSelector()] = MD;
1748 if (MethodMap.empty())
1750 for (
const auto *Method : CAT->
methods()) {
1751 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
1755 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
1756 << Method->getDeclName();
1774 IdentPair.second, AtProtocolLoc,
1786 DeclsInGroup.push_back(PDecl);
1796 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
1806 diag::err_category_forward_interface,
1807 CategoryName ==
nullptr)) {
1812 ClassLoc, CategoryLoc, CategoryName,
1813 IDecl, typeParamList);
1818 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1823 Diag(ClassLoc, diag::err_class_extension_after_impl) << ClassName;
1825 diag::note_implementation_declared);
1833 Diag(CategoryLoc, diag::warn_dup_category_def)
1834 << ClassName << CategoryName;
1835 Diag(
Previous->getLocation(), diag::note_previous_definition);
1840 if (typeParamList) {
1845 : TypeParamListContext::Extension))
1846 typeParamList =
nullptr;
1849 diag::err_objc_parameterized_category_nonclass)
1850 << (CategoryName !=
nullptr)
1854 typeParamList =
nullptr;
1859 ClassLoc, CategoryLoc, CategoryName, IDecl,
1872 NumProtoRefs, ProtoLocs);
1909 ClassLoc, AtCatImplLoc, CatLoc);
1912 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1915 diag::err_undef_interface)) {
1924 if (IDecl && IDecl->
hasAttr<ObjCRuntimeVisibleAttr>()) {
1925 Diag(ClassLoc, diag::err_objc_runtime_visible_category)
1932 Diag(ClassLoc, diag::err_dup_implementation_category) << ClassName
1935 diag::note_previous_definition);
1960 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1961 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
1963 }
else if ((IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl))) {
1967 diag::warn_undef_interface);
1973 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(),
CTK_NonError);
1979 PDiag(diag::warn_undef_interface_suggest) << ClassName,
1982 Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
1988 if (SuperClassname) {
1992 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1993 Diag(SuperClassLoc, diag::err_redefinition_different_kind)
1997 SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
2001 Diag(SuperClassLoc, diag::err_undef_superclass)
2002 << SuperClassname << ClassName;
2006 Diag(SuperClassLoc, diag::err_conflicting_super_class)
2045 ClassLoc, AtClassImplLoc, SuperClassLoc);
2053 Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
2055 diag::note_previous_definition);
2069 Diag(ClassLoc, diag::err_objc_runtime_visible_subclass)
2080 DeclsInGroup.reserve(Decls.size() + 1);
2082 for (
unsigned i = 0, e = Decls.size(); i != e; ++i) {
2083 Decl *Dcl = Decls[i];
2088 DeclsInGroup.push_back(Dcl);
2091 DeclsInGroup.push_back(ObjCImpDecl);
2099 assert(ImpDecl &&
"missing implementation decl");
2109 for (
unsigned i = 0, e = numIvars; i != e; ++i) {
2121 assert(ivars &&
"missing @implementation ivars");
2125 for (
unsigned i = 0; i < numIvars; i++) {
2130 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2138 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
2155 for (; numIvars > 0 && IVI != IVE; ++IVI) {
2158 assert (ImplIvar &&
"missing implementation ivar");
2159 assert (ClsIvar &&
"missing class ivar");
2171 diag::err_conflicting_ivar_bitwidth)
2174 diag::note_previous_definition);
2186 Diag(ivars[j]->getLocation(), diag::err_inconsistent_ivar_count);
2187 else if (IVI != IVE)
2188 Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
2193 bool &IncompleteImpl,
2215 S.
Diag(MethodLoc, diag::note_method_declared_at) << method;
2293 (y & ~
Decl::OBJC_TQ_CSNullability);
2299 bool IsProtocolMethodDecl,
2300 bool IsOverridingMode,
2302 if (IsProtocolMethodDecl &&
2308 ? diag::warn_conflicting_overriding_ret_type_modifiers
2309 : diag::warn_conflicting_ret_type_modifiers))
2318 if (Warn && IsOverridingMode &&
2323 auto nullabilityMethodImpl =
2325 auto nullabilityMethodDecl =
2328 diag::warn_conflicting_nullability_attr_overriding_ret_types)
2330 nullabilityMethodImpl,
2334 nullabilityMethodDecl,
2347 IsOverridingMode ? diag::warn_conflicting_overriding_ret_types
2348 : diag::warn_conflicting_ret_types;
2364 IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types
2365 : diag::warn_non_covariant_ret_types;
2374 ? diag::note_previous_declaration
2375 : diag::note_previous_definition)
2385 bool IsProtocolMethodDecl,
2386 bool IsOverridingMode,
2388 if (IsProtocolMethodDecl &&
2392 if (IsOverridingMode)
2394 diag::warn_conflicting_overriding_param_modifiers)
2398 diag::warn_conflicting_param_modifiers)
2410 if (Warn && IsOverridingMode &&
2414 diag::warn_conflicting_nullability_attr_overriding_param_types)
2431 IsOverridingMode ? diag::warn_conflicting_overriding_param_types
2432 : diag::warn_conflicting_param_types;
2448 IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types
2449 : diag::warn_non_contravariant_param_types;
2455 << MethodImpl->
getDeclName() << IfaceTy << ImplTy;
2457 (IsOverridingMode ? diag::note_previous_declaration
2458 : diag::note_previous_definition))
2469 if (implFamily == declFamily)
return false;
2481 unsigned errorID = diag::err_arc_lost_method_convention;
2482 unsigned noteID = diag::note_arc_lost_method_convention;
2485 family = implFamily;
2486 errorID = diag::err_arc_gained_method_convention;
2487 noteID = diag::note_arc_gained_method_convention;
2491 enum FamilySelector {
2492 F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new
2494 FamilySelector familySelector = FamilySelector();
2497 case OMF_None: llvm_unreachable(
"logic error, no method convention");
2511 case OMF_init: familySelector = F_init;
break;
2512 case OMF_alloc: familySelector = F_alloc;
break;
2513 case OMF_copy: familySelector = F_copy;
break;
2515 case OMF_new: familySelector = F_new;
break;
2518 enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn };
2519 ReasonSelector reasonSelector;
2524 reasonSelector = R_UnrelatedReturn;
2526 reasonSelector = R_NonObjectReturn;
2529 S.
Diag(impl->
getLocation(), errorID) <<
int(familySelector) << int(reasonSelector);
2530 S.
Diag(decl->
getLocation(), noteID) <<
int(familySelector) << int(reasonSelector);
2537 bool IsProtocolMethodDecl) {
2543 IsProtocolMethodDecl,
false,
2549 IM != EM && IF != EF; ++IM, ++IF) {
2551 IsProtocolMethodDecl,
false,
true);
2556 diag::warn_conflicting_variadic);
2563 bool IsProtocolMethodDecl) {
2566 IsProtocolMethodDecl,
true,
2572 IM != EM && IF != EF; ++IM, ++IF) {
2574 IsProtocolMethodDecl,
true,
true);
2579 diag::warn_conflicting_overriding_variadic);
2588 bool IsProtocolMethodDecl) {
2596 if (MethodDecl->
hasAttr<UnavailableAttr>() ||
2597 MethodDecl->
hasAttr<DeprecatedAttr>())
2601 IsProtocolMethodDecl,
false,
false);
2606 IM != EM && IF != EF; ++IM, ++IF) {
2609 IsProtocolMethodDecl,
false,
false);
2621 diag::warn_category_method_impl_match);
2638 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>())
2640 for (
const auto *PI : PDecl->
protocols())
2663 bool& IncompleteImpl,
2671 assert (IDecl &&
"CheckProtocolMethodDefs - IDecl is null");
2687 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>()) {
2688 if (!ProtocolsExplictImpl) {
2693 ProtocolsExplictImpl->end())
2711 if (InsMap.count(fISelector))
2731 !method->isPropertyAccessor() &&
2732 !InsMap.count(method->getSelector()) &&
2748 IDecl->lookupMethod(method->getSelector(),
2752 if (C || MethodInClass->isPropertyAccessor())
2754 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2764 !ClsMap.count(method->getSelector()) &&
2771 if (C && IDecl->lookupMethod(method->getSelector(),
2777 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2786 CDecl, ProtocolsExplictImpl);
2798 bool &IncompleteImpl,
2799 bool ImmediateClass,
2800 bool WarnCategoryMethodImpl) {
2804 if (!InsMapSeen.insert(I->getSelector()).second)
2806 if (!I->isPropertyAccessor() &&
2807 !InsMap.count(I->getSelector())) {
2810 diag::warn_undef_method_impl);
2816 "Expected to find the method through lookup as well");
2818 if (ImpMethodDecl) {
2819 if (!WarnCategoryMethodImpl)
2821 isa<ObjCProtocolDecl>(CDecl));
2822 else if (!I->isPropertyAccessor())
2831 if (!ClsMapSeen.insert(I->getSelector()).second)
2833 if (!I->isPropertyAccessor() &&
2834 !ClsMap.count(I->getSelector())) {
2837 diag::warn_undef_method_impl);
2842 "Expected to find the method through lookup as well");
2844 if (ImpMethodDecl) {
2845 if (!WarnCategoryMethodImpl)
2847 isa<ObjCProtocolDecl>(CDecl));
2848 else if (!I->isPropertyAccessor())
2857 for (
auto *PI : PD->protocols())
2859 IMPDecl, PI, IncompleteImpl,
false,
2860 WarnCategoryMethodImpl);
2867 if (!WarnCategoryMethodImpl) {
2868 for (
auto *Cat : I->visible_categories())
2870 IMPDecl, Cat, IncompleteImpl,
2871 ImmediateClass && Cat->IsClassExtension(),
2872 WarnCategoryMethodImpl);
2875 for (
auto *Ext : I->visible_extensions())
2877 IMPDecl, Ext, IncompleteImpl,
false,
2878 WarnCategoryMethodImpl);
2882 for (
auto *PI : I->all_referenced_protocols())
2884 IMPDecl, PI, IncompleteImpl,
false,
2885 WarnCategoryMethodImpl);
2889 if (!WarnCategoryMethodImpl && I->getSuperClass())
2892 I->getSuperClass(), IncompleteImpl,
false);
2923 if (SuperIDecl && SuperIDecl->
lookupMethod(Sel,
false))
2927 if (InsMap.empty() && ClsMap.empty())
2931 bool IncompleteImpl =
false;
2934 IncompleteImpl,
false,
2940 bool IncompleteImpl) {
2945 InsMap.insert(I->getSelector());
2953 const auto *
P = PImpl->getPropertyDecl();
2956 InsMap.insert(
P->getGetterName());
2957 if (!
P->getSetterName().isNull())
2958 InsMap.insert(
P->getSetterName());
2965 bool SynthesizeProperties =
LangOpts.ObjCDefaultSynthProperties &&
2967 !IDecl->isObjCRequiresPropertyDefs();
2976 ClsMap.insert(I->getSelector());
2983 IncompleteImpl,
true);
2988 dyn_cast<ObjCCategoryImplDecl>(IMPDecl))
2999 for (
auto *PI : I->all_referenced_protocols())
3001 InsMap, ClsMap, I, ExplicitImplProtocols);
3005 if (!
C->IsClassExtension()) {
3006 for (
auto *
P :
C->protocols())
3008 IncompleteImpl, InsMap, ClsMap, CDecl,
3009 ExplicitImplProtocols);
3014 llvm_unreachable(
"invalid ObjCContainerDecl type.");
3024 for (
unsigned i = 0; i != NumElts; ++i) {
3029 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
3039 Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
3047 Diag(AtClassLoc, diag::warn_forward_class_redefinition)
3057 = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
3079 if (PrevIDecl && TypeParams) {
3083 *
this, PrevTypeParams, TypeParams,
3084 TypeParamListContext::ForwardDeclaration)) {
3085 TypeParams =
nullptr;
3089 Diag(IdentLocs[i], diag::err_objc_parameterized_forward_class)
3092 Diag(Def->getLocation(), diag::note_defined_here)
3095 TypeParams =
nullptr;
3101 ClassName, TypeParams, PrevIDecl,
3107 DeclsInGroup.push_back(IDecl);
3115 const Type *left,
const Type *right);
3124 if (left == right)
return true;
3147 if (isa<VectorType>(left))
return isa<VectorType>(right);
3148 if (isa<VectorType>(right))
return false;
3171 return (leftSK == rightSK);
3177 assert(lt && rt && lt != rt);
3179 if (!isa<RecordType>(lt) || !isa<RecordType>(rt))
return false;
3180 RecordDecl *left = cast<RecordType>(lt)->getDecl();
3181 RecordDecl *right = cast<RecordType>(rt)->getDecl();
3187 if ((isa<CXXRecordDecl>(left) && !cast<CXXRecordDecl>(left)->isPOD()) ||
3188 (isa<CXXRecordDecl>(right) && !cast<CXXRecordDecl>(right)->isPOD()))
3203 for (; li != le && ri != re; ++li, ++ri) {
3204 if (!
matchTypes(Context, strategy, li->getType(), ri->getType()))
3207 return (li == le && ri == re);
3225 (left->
hasAttr<NSReturnsRetainedAttr>()
3226 != right->
hasAttr<NSReturnsRetainedAttr>() ||
3227 left->
hasAttr<NSConsumesSelfAttr>()
3228 != right->
hasAttr<NSConsumesSelfAttr>()))
3235 for (; li != le && ri != re; ++li, ++ri) {
3236 assert(ri != right->
param_end() &&
"Param mismatch");
3239 if (!
matchTypes(Context, strategy, lparm->getType(), rparm->getType()))
3243 lparm->hasAttr<NSConsumedAttr>() != rparm->hasAttr<NSConsumedAttr>())
3252 auto *MethodInListProtocol =
3256 if ((MethodProtocol && !MethodInListProtocol) ||
3257 (!MethodProtocol && MethodInListProtocol))
3260 if (MethodProtocol && MethodInListProtocol)
3266 return MethodInterface == MethodInListInterface;
3275 if (!CD->IsClassExtension() && List->
getBits() < 2)
3289 for (; List; Previous = List, List = List->
getNext()) {
3306 if (!SameDeclaration ||
3312 List->setHasMoreThanOneDecl(
true);
3318 ListWithSameDeclaration = List;
3321 !ListWithSameDeclaration &&
3323 ListWithSameDeclaration = List;
3337 List->setHasMoreThanOneDecl(
true);
3344 List->setMethod(Method);
3350 List->setMethod(Method);
3361 if (ListWithSameDeclaration) {
3364 ListWithSameDeclaration->
setMethod(Method);
3365 ListWithSameDeclaration->
setNext(List);
3375 assert(ExternalSource &&
"We need an external AST source");
3376 ExternalSource->ReadMethodPool(Sel);
3380 if (!ExternalSource)
3382 ExternalSource->updateOutOfDateSelector(Sel);
3385 void Sema::AddMethodToGlobalPool(
ObjCMethodDecl *Method,
bool impl,
3401 ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
3435 assert(BoundInterface &&
"unexpected object type!");
3440 if (MethodProtocol) {
3450 return MethodInterface == BoundInterface ||
3451 MethodInterface->isSuperClassOf(BoundInterface) ||
3452 BoundInterface->isSuperClassOf(MethodInterface);
3454 llvm_unreachable(
"unknown method context");
3461 bool InstanceFirst,
bool CheckTheOther,
3466 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3474 if (M->getMethod() && !M->getMethod()->isHidden()) {
3476 Methods.push_back(M->getMethod());
3480 if (!Methods.empty())
3481 return Methods.size() > 1;
3490 if (M->getMethod() && !M->getMethod()->isHidden()) {
3492 Methods.push_back(M->getMethod());
3495 return Methods.size() > 1;
3503 FilteredMethods.push_back(BestMethod);
3505 for (
auto *M : Methods)
3506 if (M != BestMethod && !M->
hasAttr<UnavailableAttr>())
3507 FilteredMethods.push_back(M);
3509 if (FilteredMethods.size() > 1)
3513 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3524 bool receiverIdOrClass,
3529 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3534 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
3537 if (M->getMethod() && !M->getMethod()->isHidden())
3538 return M->getMethod();
3545 bool receiverIdOrClass) {
3547 bool issueDiagnostic =
false, issueError =
false;
3551 bool strictSelectorMatch =
3552 receiverIdOrClass &&
3554 if (strictSelectorMatch) {
3555 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3557 issueDiagnostic =
true;
3566 if (!strictSelectorMatch ||
3567 (issueDiagnostic &&
getLangOpts().ObjCAutoRefCount))
3568 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3572 issueDiagnostic =
true;
3579 if (issueDiagnostic) {
3581 Diag(R.
getBegin(), diag::err_arc_multiple_method_decl) << Sel << R;
3582 else if (strictSelectorMatch)
3583 Diag(R.
getBegin(), diag::warn_strict_multiple_method_decl) << Sel << R;
3585 Diag(R.
getBegin(), diag::warn_multiple_method_decl) << Sel << R;
3587 Diag(Methods[0]->getBeginLoc(),
3588 issueError ? diag::note_possibility : diag::note_using)
3589 << Methods[0]->getSourceRange();
3590 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3591 Diag(Methods[I]->getBeginLoc(), diag::note_also_found)
3592 << Methods[I]->getSourceRange();
3598 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3604 Method = Method->getNext())
3605 if (Method->getMethod() &&
3608 return Method->getMethod();
3611 Method = Method->getNext())
3612 if (Method->getMethod() &&
3615 return Method->getMethod();
3623 const unsigned MaxEditDistance = 1;
3624 unsigned BestEditDistance = MaxEditDistance + 1;
3627 unsigned MinPossibleEditDistance =
abs((
int)MethodName.size() - (int)Typo.size());
3628 if (MinPossibleEditDistance > 0 &&
3629 Typo.size() / MinPossibleEditDistance < 1)
3631 unsigned EditDistance = Typo.edit_distance(MethodName,
true, MaxEditDistance);
3632 if (EditDistance > MaxEditDistance)
3634 if (EditDistance == BestEditDistance)
3635 BestMethod.push_back(Method);
3636 else if (EditDistance < BestEditDistance) {
3638 BestMethod.push_back(Method);
3657 bool ObjectIsId =
true, ObjectIsClass =
true;
3659 ObjectIsId = ObjectIsClass =
false;
3664 ObjectType =
QualType(ObjCPtr->getInterfaceType(), 0);
3665 ObjectIsId = ObjectIsClass =
false;
3668 ObjectIsClass =
false;
3674 for (GlobalMethodPool::iterator b =
MethodPool.begin(),
3678 if (M->getMethod() &&
3679 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3680 (M->getMethod()->getSelector() != Sel)) {
3682 Methods.push_back(M->getMethod());
3683 else if (!ObjectIsClass &&
3686 Methods.push_back(M->getMethod());
3690 if (M->getMethod() &&
3691 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3692 (M->getMethod()->getSelector() != Sel)) {
3694 Methods.push_back(M->getMethod());
3695 else if (!ObjectIsId &&
3698 Methods.push_back(M->getMethod());
3703 for (
unsigned i = 0, e = Methods.size(); i < e; i++) {
3707 return (SelectedMethods.size() == 1) ? SelectedMethods[0] :
nullptr;
3717 for (
auto *Ivar : ID->
ivars()) {
3718 if (Ivar->isInvalidDecl())
3723 Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
3725 Ivar->setInvalidDecl();
3737 if (ivar->isInvalidDecl())
continue;
3740 S.
Diag(ivar->getLocation(), diag::err_arc_weak_disabled);
3742 S.
Diag(ivar->getLocation(), diag::err_arc_weak_no_runtime);
3756 if (ivar->isInvalidDecl())
3762 S.
Diag(ivar->getLocation(), diag::err_flexible_array_arc_retainable);
3763 ivar->setInvalidDecl();
3770 case Decl::ObjCInterface:
3772 case Decl::ObjCProtocol:
3774 case Decl::ObjCCategory:
3775 if (cast<ObjCCategoryDecl>(
CurContext)->IsClassExtension())
3778 case Decl::ObjCImplementation:
3780 case Decl::ObjCCategoryImpl:
3792 return (RecordTy && RecordTy->getDecl()->hasFlexibleArrayMember());
3799 if ((IntfDecl = dyn_cast<ObjCInterfaceDecl>(OCD))) {
3800 Ivars = IntfDecl->
ivars();
3801 }
else if (
auto *ImplDecl = dyn_cast<ObjCImplementationDecl>(OCD)) {
3802 IntfDecl = ImplDecl->getClassInterface();
3803 Ivars = ImplDecl->
ivars();
3804 }
else if (
auto *CategoryDecl = dyn_cast<ObjCCategoryDecl>(OCD)) {
3805 if (CategoryDecl->IsClassExtension()) {
3806 IntfDecl = CategoryDecl->getClassInterface();
3807 Ivars = CategoryDecl->
ivars();
3812 if (!isa<ObjCInterfaceDecl>(OCD)) {
3813 for (
auto ivar : Ivars) {
3815 S.
Diag(ivar->getLocation(), diag::warn_variable_sized_ivar_visibility)
3816 << ivar->getDeclName() << ivar->getType();
3828 if (ivar->isInvalidDecl() || !ivar->getNextIvar())
3831 bool IsInvalidIvar =
false;
3833 S.
Diag(ivar->getLocation(), diag::err_flexible_array_not_at_end)
3834 << ivar->getDeclName() << IvarTy
3836 IsInvalidIvar =
true;
3838 if (RecordTy->getDecl()->hasFlexibleArrayMember()) {
3839 S.
Diag(ivar->getLocation(),
3840 diag::err_objc_variable_sized_type_not_at_end)
3841 << ivar->getDeclName() << IvarTy;
3842 IsInvalidIvar =
true;
3845 if (IsInvalidIvar) {
3846 S.
Diag(ivar->getNextIvar()->getLocation(),
3847 diag::note_next_ivar_declaration)
3848 << ivar->getNextIvar()->getSynthesize();
3849 ivar->setInvalidDecl();
3857 (Ivars.begin() == Ivars.end()) ?
nullptr : *Ivars.begin();
3860 while (SuperClass && SuperClass->
ivar_empty())
3864 std::advance(IvarIter, SuperClass->
ivar_size() - 1);
3868 diag::warn_superclass_variable_sized_type_not_at_end)
3869 << FirstIvar->
getDeclName() << LastIvar->getDeclName()
3870 << LastIvar->getType() << SuperClass->
getDeclName();
3871 S.
Diag(LastIvar->getLocation(), diag::note_entity_declared_at)
3872 << LastIvar->getDeclName();
3884 assert(AtEnd.
isValid() &&
"Invalid location for '@end'");
3886 auto *OCD = cast<ObjCContainerDecl>(
CurContext);
3887 Decl *ClassDecl = OCD;
3889 bool isInterfaceDeclKind =
3890 isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl)
3891 || isa<ObjCProtocolDecl>(ClassDecl);
3892 bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
3895 llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap;
3896 llvm::DenseMap<Selector, const ObjCMethodDecl*> ClsMap;
3898 for (
unsigned i = 0, e = allMethods.size(); i != e; i++ ) {
3900 cast_or_null<ObjCMethodDecl>(allMethods[i]);
3902 if (!Method)
continue;
3908 if ((isInterfaceDeclKind && PrevMethod && !match)
3909 || (checkIdenticalMethods && match)) {
3932 if ((isInterfaceDeclKind && PrevMethod && !match)
3933 || (checkIdenticalMethods && match)) {
3952 if (isa<ObjCInterfaceDecl>(ClassDecl)) {
3959 if (
C->IsClassExtension()) {
3965 if (CDecl->getIdentifier())
3969 for (
auto *I : CDecl->properties())
3971 CDecl->setAtEndRange(AtEnd);
3974 IC->setAtEndRange(AtEnd);
3981 for (
const auto *Ext : IDecl->visible_extensions()) {
3982 for (
const auto *
Property : Ext->instance_properties()) {
3985 = IC->FindPropertyImplDecl(
Property->getIdentifier(),
3987 if (PIDecl->getPropertyImplementation()
3991 for (
const auto *Ext : IDecl->visible_extensions()) {
3993 = Ext->getInstanceMethod(
Property->getGetterName()))
3994 GetterMethod->setPropertyAccessor(
true);
3997 = Ext->getInstanceMethod(
Property->getSetterName()))
3998 SetterMethod->setPropertyAccessor(
true);
4006 if (IDecl->hasDesignatedInitializers())
4011 bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>();
4012 if (IDecl->getSuperClass() ==
nullptr) {
4015 if (!HasRootClassAttr) {
4018 Diag(DeclLoc, diag::warn_objc_root_class_missing)
4019 << IDecl->getIdentifier();
4026 if (NSObjectDecl && NSObjectDecl->getDefinition()) {
4027 Diag(SuperClassLoc, diag::note_objc_needs_superclass)
4030 Diag(SuperClassLoc, diag::note_objc_needs_superclass);
4033 }
else if (HasRootClassAttr) {
4035 Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass);
4043 if (IDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4044 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4045 Diag(IC->getLocation(), diag::err_restricted_superclass_mismatch);
4046 Diag(Super->getLocation(), diag::note_class_declared);
4051 while (IDecl->getSuperClass()) {
4053 IDecl = IDecl->getSuperClass();
4059 dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
4060 CatImplClass->setAtEndRange(AtEnd);
4066 = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier())) {
4070 }
else if (
const auto *IntfDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
4072 if (!IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4073 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4074 Diag(IntfDecl->getLocation(), diag::err_restricted_superclass_mismatch);
4075 Diag(Super->getLocation(), diag::note_class_declared);
4080 if (isInterfaceDeclKind) {
4082 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4085 if (
VarDecl *VDecl = dyn_cast<VarDecl>(*I)) {
4086 if (!VDecl->hasExternalStorage())
4087 Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass);
4093 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4096 (*I)->setTopLevelDeclInObjCContainer();
4125 if (ResultObjectType->isObjCIdType() ||
4126 ResultObjectType->isObjCQualifiedIdType())
4131 = ResultObjectType->getInterfaceDecl()) {
4137 if (ResultClass->isSuperClassOf(CurrentClass))
4153 class OverrideSearch {
4166 Sema::GlobalMethodPool::iterator it = S.
MethodPool.find(selector);
4186 searchFromContainer(container);
4188 searchFromContainer(Interface);
4190 searchFromContainer(container);
4194 typedef decltype(Overridden)::iterator iterator;
4195 iterator begin()
const {
return Overridden.begin(); }
4196 iterator end()
const {
return Overridden.end(); }
4203 #define OBJCCONTAINER(type, base) \ 4205 searchFrom(cast<type##Decl>(container)); \ 4207 #define ABSTRACT_DECL(expansion) 4208 #define DECL(type, base) \ 4210 #include "clang/AST/DeclNodes.inc" 4211 llvm_unreachable(
"not an ObjC container!");
4284 Overridden.insert(meth);
4294 searchFromContainer(container);
4303 OverrideSearch overrides(*
this, ObjCMethod);
4309 bool hasOverriddenMethodsInBaseOrProtocol =
false;
4310 for (OverrideSearch::iterator
4311 i = overrides.begin(), e = overrides.end(); i != e; ++i) {
4314 if (!hasOverriddenMethodsInBaseOrProtocol) {
4318 hasOverriddenMethodsInBaseOrProtocol =
true;
4328 GlobalMethodPool::iterator It =
4333 unsigned CategCount = List.
getBits();
4334 if (CategCount > 0) {
4337 if (CategCount > 1 ||
4339 OverrideSearch overrides(*
this, overridden);
4340 for (OverrideSearch::iterator
4341 OI= overrides.begin(), OE= overrides.end(); OI!=OE; ++OI) {
4345 hasOverriddenMethodsInBaseOrProtocol =
true;
4372 if (CurrentClass && overridden->
getDeclContext() != CurrentClass &&
4379 for (; ParamI != E && PrevI != PrevE; ++ParamI, ++PrevI) {
4380 assert(PrevI != overridden->
param_end() &&
"Param mismatch");
4386 Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
4395 ObjCMethod->
setOverriding(hasOverriddenMethodsInBaseOrProtocol);
4405 bool prevUsesCSKeyword) {
4411 if (nullability.hasValue() == prevNullability.hasValue()) {
4417 if (*nullability == *prevNullability)
4421 S.
Diag(loc, diag::err_nullability_conflicting)
4444 if (prevMethod->
hasAttr<ObjCRequiresSuperAttr>() &&
4445 !method->
hasAttr<ObjCRequiresSuperAttr>()) {
4448 ObjCRequiresSuperAttr::CreateImplicit(S.
Context,
4465 unsigned numPrevParams = prevMethod->
param_size();
4466 for (
unsigned i = 0, n =
std::min(numParams, numPrevParams); i != n; ++i) {
4486 llvm::Triple::x86 &&
4487 "x86-specific check invoked for a different target");
4491 if (
P->getType()->isVectorType()) {
4492 Loc =
P->getBeginLoc();
4497 if (Loc.isInvalid()) {
4508 VersionTuple AcceptedInVersion;
4509 if (Triple.getOS() == llvm::Triple::IOS)
4510 AcceptedInVersion = VersionTuple(9);
4511 else if (Triple.isMacOSX())
4512 AcceptedInVersion = VersionTuple(10, 11);
4518 SemaRef.
Diag(Loc, diag::err_objc_method_unsupported_param_ret_type)
4521 << (Triple.isMacOSX() ?
"macOS 10.11" :
"iOS 9");
4533 bool isVariadic,
bool MethodDefinition) {
4536 Diag(MethodLoc, diag::err_missing_method_context);
4542 bool HasRelatedResultType =
false;
4550 QualType bareResultType = resultDeclType;
4555 Diag(MethodLoc, diag::warn_missing_method_return_type)
4560 Context, MethodLoc, EndLoc, Sel, resultDeclType, ReturnTInfo,
CurContext,
4561 MethodType == tok::minus, isVariadic,
4566 HasRelatedResultType);
4570 for (
unsigned i = 0, e = Sel.
getNumArgs(); i != e; ++i) {
4574 if (!ArgInfo[i].
Type) {
4581 LookupResult R(*
this, ArgInfo[i].Name, ArgInfo[i].NameLoc,
4587 Diag(ArgInfo[i].NameLoc,
4588 (MethodDefinition ? diag::warn_method_param_redefinition
4589 : diag::warn_method_param_declaration))
4592 diag::note_previous_declaration);
4601 ArgInfo[i].NameLoc, ArgInfo[i].Name,
4613 if (Param->
hasAttr<BlocksAttr>()) {
4620 Params.push_back(Param);
4623 for (
unsigned i = 0, e = CNumArgs; i != e; ++i) {
4626 if (ArgType.isNull())
4633 Params.push_back(Param);
4636 ObjCMethod->setMethodParams(Context, Params, SelectorLocs);
4637 ObjCMethod->setObjCDeclQualifier(
4645 if (
ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(ClassDecl)) {
4646 if (MethodType == tok::minus) {
4647 PrevMethod = ImpDecl->getInstanceMethod(Sel);
4648 ImpDecl->addInstanceMethod(ObjCMethod);
4650 PrevMethod = ImpDecl->getClassMethod(Sel);
4651 ImpDecl->addClassMethod(ObjCMethod);
4657 if (
auto *IMD = IDecl->lookupMethod(ObjCMethod->getSelector(),
4658 ObjCMethod->isInstanceMethod())) {
4662 if (isa<ObjCCategoryImplDecl>(ImpDecl) && IMD->isOverriding() &&
4663 ObjCMethod->getSelector().getMethodFamily() ==
OMF_dealloc) {
4664 Diag(ObjCMethod->getLocation(), diag::warn_dealloc_in_category)
4665 << ObjCMethod->getDeclName();
4672 for (
auto *
C : IDecl->visible_categories())
4673 for (
auto &
P :
C->protocols())
4674 if (
auto *IMD =
P->lookupMethod(ObjCMethod->getSelector(),
4675 ObjCMethod->isInstanceMethod())) {
4676 assert(ObjCMethod->parameters().size() ==
4677 IMD->parameters().size() &&
4678 "Methods have different number of parameters");
4679 auto OI = IMD->param_begin(), OE = IMD->param_end();
4680 auto NI = ObjCMethod->param_begin();
4681 for (; OI != OE; ++OI, ++NI)
4686 cast<DeclContext>(ClassDecl)->addDecl(ObjCMethod);
4691 Diag(ObjCMethod->getLocation(), diag::err_duplicate_method_decl)
4692 << ObjCMethod->getDeclName();
4694 ObjCMethod->setInvalidDecl();
4702 if (!CurrentClass) {
4704 CurrentClass = Cat->getClassInterface();
4705 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(ClassDecl))
4706 CurrentClass = Impl->getClassInterface();
4708 = dyn_cast<ObjCCategoryImplDecl>(ClassDecl))
4709 CurrentClass = CatImpl->getClassInterface();
4717 bool ARCError =
false;
4723 !ObjCMethod->hasRelatedResultType() &&
4724 LangOpts.ObjCInferRelatedResultType) {
4725 bool InferRelatedResultType =
false;
4726 switch (ObjCMethod->getMethodFamily()) {
4740 InferRelatedResultType = ObjCMethod->isClassMethod();
4747 InferRelatedResultType = ObjCMethod->isInstanceMethod();
4751 if (InferRelatedResultType &&
4752 !ObjCMethod->getReturnType()->isObjCIndependentClassType())
4753 ObjCMethod->setRelatedResultType();
4756 if (MethodDefinition &&
4762 if (
const auto *attr = ObjCMethod->getAttr<AvailabilityAttr>()) {
4763 if (ObjCMethod->isClassMethod() &&
4764 ObjCMethod->getSelector().getAsString() ==
"load") {
4765 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
4767 ObjCMethod->dropAttr<AvailabilityAttr>();
4787 Diag(D->
getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
4801 Diag(DeclStart, diag::err_undef_interface) << ClassName;
4805 Diag(DeclStart, diag::err_atdef_nonfragile_interface);
4813 for (
unsigned i = 0; i < Ivars.size(); i++) {
4821 Decls.push_back(FD);
4826 D != Decls.end(); ++D) {
4830 else if (
RecordDecl *Record = dyn_cast<RecordDecl>(TagD))
4831 Record->addDecl(FD);
4846 Diag(IdLoc, diag::err_arg_with_address_space);
4858 Diag(IdLoc, diag::err_illegal_qualifiers_on_catch_parm);
4863 Diag(IdLoc, diag::err_catch_param_not_objc_type);
4866 Diag(IdLoc, diag::err_catch_param_not_objc_type);
4899 diag::err_invalid_thread)
4933 if (New->
hasAttr<BlocksAttr>())
4946 Ivars.push_back(Iv);
4952 if (ExternalSource) {
4954 ExternalSource->ReadReferencedSelectors(Sels);
4955 for (
unsigned I = 0, N = Sels.size(); I != N; ++I)
4966 Selector Sel = SelectorAndLocation.first;
4969 Diag(Loc, diag::warn_unimplemented_selector) << Sel;
4992 IV->getIdentifier());
5001 class UnusedBackingIvarChecker :
5008 bool InvokedSelfMethod;
5012 : S(S), Method(Method), IvarD(IvarD),
5013 AccessedIvar(
false), InvokedSelfMethod(
false) {
5019 AccessedIvar =
true;
5028 InvokedSelfMethod =
true;
5041 unsigned DIAG = diag::warn_unused_property_backing_ivar;
5051 UnusedBackingIvarChecker Checker(*
this, CurMethod, IV);
5052 Checker.TraverseStmt(CurMethod->getBody());
5053 if (Checker.AccessedIvar)
5060 if (!IV->
isReferenced() || !Checker.InvokedSelfMethod) {
5061 Diag(Loc, DIAG) << IV;
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl *> allMethods=None, ArrayRef< DeclGroupPtrTy > allTUVars=None)
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
bool hasDefinition() const
Determine whether this class has been defined.
static bool tryMatchRecordTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, const Type *left, const Type *right)
ObjCIvarDecl * GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, const ObjCPropertyDecl *&PDecl) const
GetIvarBackingPropertyAccessor - If method is a property setter/getter and it property has a backing ...
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, ObjCInterfaceDecl *ID)
DiagnoseClassExtensionDupMethods - Check for duplicate declaration of a class method in its extension...
bool isClassMethod() const
Decl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
void setImplicit(bool I=true)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
The receiver is an object instance.
void setEndOfDefinitionLoc(SourceLocation LE)
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled...
ExternalSemaSource * getExternalSource() const
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, ExpressionEvaluationContextRecord::ExpressionKind Type=ExpressionEvaluationContextRecord::EK_Other)
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
void setStarLoc(SourceLocation Loc)
unsigned param_size() const
ObjCInterfaceDecl * getClassInterface()
all_protocol_range all_referenced_protocols() const
ObjCInterfaceDecl * getClassInterface()
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass, SmallVectorImpl< ObjCMethodDecl *> &Methods)
ObjCDeclQualifier getObjCDeclQualifier() const
static QualType getObjectType(APValue::LValueBase B)
Retrieves the "underlying object type" of the given expression, as used by __builtin_object_size.
static ClassTemplateDecl * getDefinition(ClassTemplateDecl *D)
llvm::DenseSet< IdentifierInfo * > ProtocolNameSet
FIXME: Type hierarchies in Objective-C can be deep.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
Look up the name of an Objective-C protocol.
const ObjCProtocolList & getReferencedProtocols() const
Expr * getBitWidth() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
static bool CheckMethodOverrideParam(Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, ParmVarDecl *ImplVar, ParmVarDecl *IfaceVar, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn)
Defines the SourceManager interface.
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
bool isRecordType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
__DEVICE__ long long abs(long long __n)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AL, bool IncludeCXX11Attributes=true)
Captures information about "declaration specifiers" specific to Objective-C.
ObjCTypeParamList * actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef< Decl *> typeParams, SourceLocation rAngleLoc)
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl, ObjCProtocolDecl *&UndefinedProtocol)
known_categories_range known_categories() const
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
bool CheckForwardProtocolDeclarationForCircularDependency(IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, const ObjCList< ObjCProtocolDecl > &PList)
The base class of the type hierarchy.
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
The parameter is covariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant and ...
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
bool isCompilingModule() const
Are we compiling a module interface (.cppm or module map)?
bool isObjCContainer() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getEndLoc() const LLVM_READONLY
const TargetInfo & getTargetInfo() const
A container of type source information.
void ProcessPropertyDecl(ObjCPropertyDecl *property)
Process the specified property declaration and create decls for the setters and getters as needed...
ObjCMethodDecl * getMethod() const
TSCS getThreadStorageClassSpec() const
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...
param_const_iterator param_end() const
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
SourceLocation getEndLoc() const
Get the end source location.
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implict parameters. ...
Represents a variable declaration or definition.
void setImplementation(ObjCCategoryImplDecl *ImplD)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Information about one declarator, including the parsed type information and the identifier.
DiagnosticsEngine & Diags
const T * getAs() const
Member-template getAs<specific type>'.
ObjCCategoryImplDecl * getImplementation() const
static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc, ObjCMethodDecl *method, bool &IncompleteImpl, unsigned DiagID, NamedDecl *NeededFor=nullptr)
ObjCMethodDecl - Represents an instance or class method declaration.
DeclClass * getCorrectionDeclAs() const
bool isInvalidDecl() const
classmeth_range class_methods() const
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
protocol_range protocols() const
Represents a parameter to a function.
The collection of all-type qualifiers we support.
const ObjCInterfaceDecl * getSuperClass() const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
Represents a struct/union/class.
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
static void checkObjCMethodX86VectorTypes(Sema &SemaRef, const ObjCMethodDecl *Method)
Verify that the method parameters/return value have types that are supported by the x86 target...
const ObjCProtocolList & getReferencedProtocols() const
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
const ParmVarDecl *const * param_const_iterator
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
ObjCMethodFamily
A family of Objective-C methods.
The parameter is contravariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant ...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
void set(T *const *InList, unsigned Elts, ASTContext &Ctx)
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isObjCIdType() const
Represents a member of a struct/union/class.
SourceRange getReturnTypeSourceRange() const
instmeth_range instance_methods() const
void setSuperClass(TypeSourceInfo *superClass)
method_range methods() const
SourceRange getSourceRange() const
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList *> TypeParamLists, unsigned NumElts)
void ClearStorageClassSpecs()
void setReturnType(QualType T)
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc, SourceLocation UnalignedQualLoc)
Return a DeclaratorChunk for a pointer.
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...
bool isObjCQualifiedClassType() const
static bool FilterMethodsByTypeBound(ObjCMethodDecl *Method, const ObjCObjectType *TypeBound)
Return true if the given method is wthin the type bound.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
llvm::BumpPtrAllocator BumpAlloc
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
bool isInvalidType() const
bool isUnarySelector() const
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
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...
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 setMethod(ObjCMethodDecl *M)
bool isBitField() const
Determines whether this field is a bitfield.
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
Represents the results of name lookup.
ObjCMethodDecl * LookupImplementedMethodInGlobalPool(Selector Sel)
LookupImplementedMethodInGlobalPool - Returns the method which has an implementation.
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool isReferenced() const
Whether any declaration of this entity was referenced.
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
SCS
storage-class-specifier
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl *> &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl *> Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Decl * ActOnObjCContainerStartDefinition(Decl *IDecl)
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, IdentifierInfo *ClassName, SmallVectorImpl< Decl *> &Decls)
Called whenever @defs(ClassName) is encountered in the source.
SourceLocation getBeginLoc() const LLVM_READONLY
const clang::PrintingPolicy & getPrintingPolicy() const
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Represents a declaration of a type.
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
void setExceptionVariable(bool EV)
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...
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Scope - A scope is a transient data structure that is used while parsing the program.
const ObjCMethodDecl * SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType())
static bool CheckMethodOverrideReturn(Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn)
field_iterator field_begin() const
unsigned getBitWidthValue(const ASTContext &Ctx) const
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
Represents an Objective-C protocol declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool isScalarType() const
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
Decl * ActOnObjCExceptionDecl(Scope *S, Declarator &D)
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Represents an ObjC class declaration.
QualType getReturnType() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
IdentifierInfo * getIdentifier() const
const LangOptions & LangOpts
This object can be modified without requiring retains or releases.
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
AvailabilityResult
Captures the result of checking the availability of a declaration.
static Decl::ObjCDeclQualifier CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal)
CvtQTToAstBitMask - utility routine to produce an AST bitmask for objective-c's type qualifier from t...
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
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.
static bool isAcceptableMethodMismatch(ObjCMethodDecl *chosen, ObjCMethodDecl *other)
Determines if this is an "acceptable" loose mismatch in the global method pool.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Sema - This implements semantic analysis and AST building for C.
visible_extensions_range visible_extensions() const
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
ResultTypeCompatibilityKind
Describes the compatibility of a result type with its method.
llvm::SmallPtrSet< Selector, 8 > SelectorSet
bool inferObjCARCLifetime(ValueDecl *decl)
void SetRangeStart(SourceLocation Loc)
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, const ParsedAttributesView &attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
SourceRange getRange() const
void ActOnSuperClassOfClassInterface(Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange)
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl *> Decls)
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
bool AnyObjCImplementation()
Return true if there is at least one @implementation in the TU.
unsigned ivar_size() const
TypeSourceInfo * getTypeSourceInfo() const
bool hasDefinition() const
Determine whether this protocol has a definition.
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl *> &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized, ivars in super class and then collects all ivars, including those synthesized for current class.
SourceLocation getBeginLoc() const
Get the begin source location.
Type source information for an attributed type.
LookupNameKind
Describes the kind of name lookup to perform.
ObjCMethodList * getNext() 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 isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
ivar_iterator ivar_begin() const
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
TypeResult ActOnTypeName(Scope *S, Declarator &D)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type...
static void DiagnoseObjCImplementedDeprecations(Sema &S, const NamedDecl *ND, SourceLocation ImplLoc)
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
SourceLocation getThreadStorageClassSpecLoc() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setAtEndRange(SourceRange atEnd)
void ActOnStartOfObjCMethodDef(Scope *S, Decl *D)
ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible and user declared, in the method definition's AST.
void setRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
field_iterator field_end() const
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
bool isFileContext() const
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isObjCClassType() const
DeclContext * getDeclContext()
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
ObjCInterfaceDecl * getSuperClass() const
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl *> typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
void setDefined(bool isDefined)
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
SourceLocation getStorageClassSpecLoc() const
ParmVarDecl *const * param_iterator
void setImplementation(ObjCImplementationDecl *ImplD)
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
Decl * ActOnStartClassImplementation(SourceLocation AtClassImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc)
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
static void DiagnoseWeakIvars(Sema &S, ObjCImplementationDecl *ID)
Diagnose attempts to define ARC-__weak ivars when __weak is disabled.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
clang::ObjCRuntime ObjCRuntime
propimpl_range property_impls() const
bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT, bool IsParam) const
An expression that sends a message to the given Objective-C object or class.
static void DiagnoseVariableSizedIvars(Sema &S, ObjCContainerDecl *OCD)
void WarnConflictingTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
SourceLocation getEnd() const
bool isInstanceMethod() const
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId, SourceLocation ProtocolLoc, IdentifierInfo *TypeArgId, SourceLocation TypeArgLoc, bool SelectProtocolFirst=false)
unsigned getNumArgs() const
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
CollectInheritedProtocols - Collect all protocols in current class and those inherited by it...
Selector getSelector() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
ImplicitParamDecl * getSelfDecl() const
void removeCVRQualifiers(unsigned mask)
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
ObjCDeclQualifier
ObjCDeclQualifier - Qualifier used on types in method declarations.
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
DiagnoseDuplicateIvars - Check for duplicate ivars in the entire class at the start of @implementatio...
static ObjCCompatibleAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *aliasedClass)
Decl::Kind getDeclKind() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
std::string getAsString() const
Derive the full selector name (e.g.
SelectorTable & Selectors
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
static void findProtocolsWithExplicitImpls(const ObjCProtocolDecl *PDecl, ProtocolNameSet &PNS)
static bool IsVariableSizedType(QualType T)
SCS getStorageClassSpec() const
ASTContext & getASTContext() const
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void setTopLevelDeclInObjCContainer(bool V=true)
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl *> Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
ivar_iterator ivar_end() const
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
LangAS getAddressSpace() const
Return the address space of this type.
ObjCProtocolDecl *const * iterator
Interfaces are the core concept in Objective-C for object oriented design.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
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 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...
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
static bool objcModifiersConflict(Decl::ObjCDeclQualifier x, Decl::ObjCDeclQualifier y)
Determine whether two set of Objective-C declaration qualifiers conflict.
ObjCCategoryDecl * getCategoryDecl() const
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method, and set any properties that should be inherited.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
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...
std::unique_ptr< ProtocolNameSet > LazyProtocolNameSet
void DiagnoseUseOfUnimplementedSelectors()
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
static bool isObjCTypeSubstitutable(ASTContext &Context, const ObjCObjectPointerType *A, const ObjCObjectPointerType *B, bool rejectId)
Determines if type B can be substituted for type A.
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
ObjCCategoryDecl - Represents a category declaration.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void setOverriding(bool IsOver)
Look up any declaration with any name.
Decl * 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)
bool isObjCObjectPointerType() const
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
Represents one property declaration in an Objective-C interface.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
void updateOutOfDateSelector(Selector Sel)
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
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...
ObjCDeclQualifier getObjCDeclQualifier() const
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node...
void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList)
bool isVectorType() const
SourceLocation getInlineSpecLoc() const
static bool HelperIsMethodInObjCType(Sema &S, Selector Sel, QualType ObjectType)
ObjCImplementationDecl * getImplementation() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
std::string getAsString() const
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
ObjCTypeParamDecl * back() const
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;...
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
static bool checkMethodFamilyMismatch(Sema &S, ObjCMethodDecl *impl, ObjCMethodDecl *decl)
In ARC, check whether the conventional meanings of the two methods match.
ObjCDeclQualifier getObjCDeclQualifier() const
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
ObjCIvarDecl * getNextIvar()
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Base class for declarations which introduce a typedef-name.
void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
WarnExactTypedMethods - This routine issues a warning if method implementation declaration matches ex...
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...
const ObjCInterfaceDecl * getClassInterface() const
Dataflow Directional Tag Classes.
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
bool isValid() const
Return true if this is a valid SourceLocation object.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD)
DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which backs the property is n...
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
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)
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
void CheckConflictingOverridingMethod(ObjCMethodDecl *Method, ObjCMethodDecl *Overridden, bool IsProtocolMethodDecl)
bool ObjCIsSecondaryInit
True when this is an initializer method not marked as a designated initializer within a class that ha...
QualType getUnderlyingType() const
const ObjCProtocolList & getReferencedProtocols() const
TypeParamListContext
The context in which an Objective-C type parameter list occurs, for use in diagnostics.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
Represents the declaration of an Objective-C type parameter.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
static void CheckProtocolMethodDefs(Sema &S, SourceLocation ImpLoc, 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, and those referenced by it.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
static bool matchTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, QualType leftQT, QualType rightQT)
bool hasObjCLifetime() const
IdentifierResolver IdResolver
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
Represents a pointer to an Objective C object.
static bool HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param)
HasExplicitOwnershipAttr - returns true when pointer to ObjC pointer has explicit ownership attribute...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
bool isIncompleteArrayType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setNext(ObjCMethodList *L)
static bool isMethodContextSameForKindofLookup(ObjCMethodDecl *Method, ObjCMethodDecl *MethodInList)
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
SourceLocation getSelectorLoc(unsigned Index) const
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...
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
bool isObjCQualifiedIdType() const
TypeSourceInfo * getTypeSourceInfo() const
DeclContext * getCurLexicalContext() const
static const TST TST_typename
param_const_iterator param_begin() const
Base for LValueReferenceType and RValueReferenceType.
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D)
Handle the specified top-level declaration that occurred inside and ObjC container.
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
A list of Objective-C protocols, along with the source locations at which they were referenced...
Wraps an ObjCPointerType with source location information.
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.
void addDecl(Decl *D)
Add the declaration D into this context.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
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, its categories, and its super classes (using a linear search).
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
static void DiagnoseRetainableFlexibleArrayMember(Sema &S, ObjCInterfaceDecl *ID)
Diagnose attempts to use flexible array member with retainable object type.
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 QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceManager & getSourceManager()
void setObjCMethodScopeInfo(unsigned parameterIndex)
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool hasMoreThanOneDecl() const
bool IsClassExtension() const
ImplementationControl getImplementationControl() const
RedeclarationKind forRedeclarationInCurContext()
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
ObjCInterfaceDecl * getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
bool isSet() const
Deprecated.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Reading or writing from this object requires a barrier call.
No particular method family.
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Decl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
Captures information about "declaration specifiers".
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
static void HelperSelectorsForTypoCorrection(SmallVectorImpl< const ObjCMethodDecl *> &BestMethod, StringRef Typo, const ObjCMethodDecl *Method)
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
sema::FunctionScopeInfo * getCurFunction() const
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...
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, const ObjCMethodDecl *PrevMethod, MethodMatchStrategy strategy=MMS_strict)
MatchTwoMethodDeclarations - Checks if two methods' type match and returns true, or false...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCIvarDecl * getPropertyIvarDecl() const
bool CheckObjCDeclScope(Decl *D)
Checks that the Objective-C declaration is declared in the global scope.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
ImplicitParamDecl * getCmdDecl() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
SourceManager & getSourceManager() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isInlineSpecified() const
a linked list of methods with the same selector name but different signatures.
std::pair< ObjCMethodList, ObjCMethodList > GlobalMethods
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, SHOWINSYSHEADER, CATEGORY)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
__DEVICE__ int min(int __a, int __b)
void ActOnObjCContainerFinishDefinition()
void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
A trivial tuple used to represent a source range.
bool hasUnrecoverableErrorOccurred() const
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
void setLexicalDeclContext(DeclContext *DC)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< 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...
static SourceRange getTypeRange(TypeSourceInfo *TSI)
This represents a decl that may have a name.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
void setVariance(ObjCTypeParamVariance variance)
Set the variance of this type parameter.
void setTypeSourceInfo(TypeSourceInfo *newType)
Decl * ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CatName, SourceLocation CatLoc)
ActOnStartCategoryImplementation - Perform semantic checks on the category implementation declaration...
void DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl< ObjCMethodDecl *> &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass)
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
bool isPropertyAccessor() const
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
SourceLocation getLAngleLoc() const
static void diagnoseUseOfProtocols(Sema &TheSema, ObjCContainerDecl *CD, ObjCProtocolDecl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs)
void SetRangeEnd(SourceLocation Loc)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
ObjCContainerKind getObjCContainerKind() const
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
void setType(QualType newType)
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
unsigned size() const
Determine the number of type parameters in this list.
void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP)
CheckCategoryVsClassMethodMatches - Checks that methods implemented in category matches with those im...
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
The parameter is invariant: must match exactly.
void PushFunctionScope()
Enter a new function scope.
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...
SourceLocation getLocation() const
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
QualType getType() const
Return the type wrapped by this type source info.
ArrayRef< ParmVarDecl * > parameters() const
ObjCCompatibleAliasDecl - Represents alias of a class.
Helper class that creates diagnostics with optional template instantiation stacks.
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...