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);
129 CurrentClass = Cat->getClassInterface();
130 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(DC))
131 CurrentClass = Impl->getClassInterface();
133 = dyn_cast<ObjCCategoryImplDecl>(DC))
134 CurrentClass = CatImpl->getClassInterface();
139 diag::warn_related_result_type_compatibility_class)
145 diag::warn_related_result_type_compatibility_protocol)
152 diag::note_related_result_type_family)
157 diag::note_related_result_type_overridden);
166 if ((NewMethod->
hasAttr<NSReturnsRetainedAttr>() !=
167 Overridden->
hasAttr<NSReturnsRetainedAttr>())) {
169 diag::warn_nsreturns_retained_attribute_mismatch) << 1;
172 if ((NewMethod->
hasAttr<NSReturnsNotRetainedAttr>() !=
173 Overridden->
hasAttr<NSReturnsNotRetainedAttr>())) {
175 diag::warn_nsreturns_retained_attribute_mismatch) << 0;
183 ni != ne && oi != oe; ++ni, ++oi) {
186 if (newDecl->
hasAttr<NSConsumedAttr>() !=
187 oldDecl->
hasAttr<NSConsumedAttr>()) {
188 Diag(newDecl->
getLocation(), diag::warn_nsconsumed_attribute_mismatch);
194 if (oldDecl->
hasAttr<NoEscapeAttr>() && !newDecl->
hasAttr<NoEscapeAttr>()) {
196 diag::warn_overriding_method_missing_noescape);
242 if (method->
hasAttr<NSReturnsRetainedAttr>())
250 if (method->
hasAttr<NSReturnsRetainedAttr>() ||
251 method->
hasAttr<NSReturnsNotRetainedAttr>() ||
252 method->
hasAttr<NSReturnsAutoreleasedAttr>())
265 bool IsCategory =
false;
268 if (isa<ObjCMethodDecl>(ND)) {
272 S.
Diag(ImplLoc, diag::warn_unavailable_def);
277 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND)) {
278 if (!CD->getClassInterface()->isDeprecated())
280 ND = CD->getClassInterface();
285 S.
Diag(ImplLoc, diag::warn_deprecated_def)
286 << (isa<ObjCMethodDecl>(ND)
288 : isa<ObjCCategoryDecl>(ND) || IsCategory ? 2
290 if (isa<ObjCMethodDecl>(ND))
295 << (isa<ObjCCategoryDecl>(ND) ?
"category" :
"class");
360 if (!Param->isInvalidDecl() &&
363 Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
366 if (Param->getIdentifier())
409 ImplDeclOfMethodDecl = OID->getImplementation();
410 else if (
ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContDeclOfMethodDecl)) {
411 if (CD->IsClassExtension()) {
413 ImplDeclOfMethodDecl = OID->getImplementation();
415 ImplDeclOfMethodDecl = CD->getImplementation();
419 if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
427 IC->getSuperClass() !=
nullptr;
428 }
else if (IC->hasDesignatedInitializers()) {
454 (SuperMethod && SuperMethod->
hasAttr<ObjCRequiresSuperAttr>());
467 ObjCInterfaceValidatorCCC() : CurrentIDecl(
nullptr) {}
469 : CurrentIDecl(IDecl) {}
471 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
485 unsigned NumProtoRefs,
490 for (
unsigned i = 0; i < NumProtoRefs; ++i) {
518 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(IDecl),
521 << SuperName << ClassName);
527 Diag(SuperLoc, diag::err_recursive_superclass)
528 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
532 dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
536 if (SuperClassDecl) {
541 if (PrevDecl && !SuperClassDecl) {
545 dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
566 if (!SuperClassDecl) {
567 Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
572 if (!dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
574 Diag(SuperLoc, diag::err_undef_superclass)
575 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
578 diag::err_forward_superclass,
581 SourceRange(AtInterfaceLoc, ClassLoc))) {
582 SuperClassDecl =
nullptr;
587 if (SuperClassType.isNull()) {
588 assert(!SuperClassDecl &&
"Failed to set SuperClassType?");
594 if (!SuperTypeArgs.empty()) {
602 SuperTypeArgsRange.
getEnd(),
614 if (!SuperClassTInfo) {
634 if (parsedTypeBound) {
645 diag::err_objc_type_param_bound_missing_pointer)
646 << typeBound << paramName
665 diag::err_objc_type_param_bound_nonobject)
666 << typeBound << paramName;
669 typeBoundInfo =
nullptr;
678 bool diagnosed =
false;
682 rangeToRemove = attr.getLocalSourceRange();
683 if (attr.getTypePtr()->getImmediateNullability()) {
684 Diag(attr.getLocStart(),
685 diag::err_objc_type_param_bound_explicit_nullability)
686 << paramName << typeBound
696 diag::err_objc_type_param_bound_qualified)
706 if (!quals.
empty()) {
716 if (!typeBoundInfo) {
723 index, paramLoc, paramName, colonLoc,
734 reinterpret_cast<ObjCTypeParamDecl * const *>(typeParamsIn.data()),
735 typeParamsIn.size());
741 llvm::SmallDenseMap<IdentifierInfo *, ObjCTypeParamDecl *> knownParams;
742 for (
auto typeParam : typeParams) {
743 auto known = knownParams.find(typeParam->getIdentifier());
744 if (known != knownParams.end()) {
745 Diag(typeParam->getLocation(), diag::err_objc_type_param_redecl)
746 << typeParam->getIdentifier()
749 typeParam->setInvalidDecl();
751 knownParams.insert(std::make_pair(typeParam->getIdentifier(), typeParam));
763 for (
auto typeParam : *typeParamList) {
764 if (!typeParam->isInvalidDecl()) {
790 if (prevTypeParams->
size() != newTypeParams->
size()) {
792 if (newTypeParams->
size() > prevTypeParams->
size()) {
798 S.
Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
799 <<
static_cast<unsigned>(newContext)
800 << (newTypeParams->
size() > prevTypeParams->
size())
801 << prevTypeParams->
size()
802 << newTypeParams->
size();
808 for (
unsigned i = 0, n = prevTypeParams->
size(); i != n; ++i) {
815 newContext != TypeParamListContext::Definition) {
834 auto diag = S.
Diag(diagLoc,
835 diag::err_objc_type_param_variance_conflict)
836 <<
static_cast<unsigned>(newTypeParam->
getVariance())
838 <<
static_cast<unsigned>(prevTypeParam->
getVariance())
847 StringRef newVarianceStr
854 (newVarianceStr +
" ").str());
881 S.
Diag(newBoundRange.
getBegin(), diag::err_objc_type_param_bound_conflict)
906 if (newContext == TypeParamListContext::ForwardDeclaration ||
907 newContext == TypeParamListContext::Definition) {
915 diag::err_objc_type_param_bound_missing)
918 << (newContext == TypeParamListContext::ForwardDeclaration)
940 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
943 assert(ClassName &&
"Missing class identifier");
950 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
951 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
958 if (PrevIDecl && PrevIDecl->getIdentifier() != ClassName) {
971 ClassName = PrevIDecl->getIdentifier();
982 TypeParamListContext::Definition)) {
983 typeParamList =
nullptr;
986 Diag(ClassLoc, diag::err_objc_parameterized_forward_class_first)
988 Diag(prevTypeParamList->getLAngleLoc(), diag::note_previous_decl)
993 for (
auto typeParam : *prevTypeParamList) {
994 clonedTypeParams.push_back(
998 typeParam->getVariance(),
1000 typeParam->getIndex(),
1002 typeParam->getIdentifier(),
1017 typeParamList, PrevIDecl, ClassLoc);
1021 Diag(AtInterfaceLoc, diag::err_duplicate_class_def)
1022 << PrevIDecl->getDeclName();
1023 Diag(Def->getLocation(), diag::note_previous_definition);
1043 ClassName, ClassLoc,
1044 SuperName, SuperLoc, SuperTypeArgs,
1045 SuperTypeArgsRange);
1053 NumProtoRefs, ProtoLocs);
1077 if (
const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) {
1078 QualType T = TDecl->getUnderlyingType();
1081 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end());
1086 ProtocolLocs.append(OPT->getNumProtocols(), SuperLoc);
1103 Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
1112 dyn_cast_or_null<TypedefNameDecl>(CDeclU)) {
1113 QualType T = TDecl->getUnderlyingType();
1116 ClassName = IDecl->getIdentifier();
1125 Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
1148 E = PList.
end(); I != E; ++I) {
1151 if (PDecl->getIdentifier() == PName) {
1152 Diag(Ploc, diag::err_protocol_has_circular_dependency);
1153 Diag(PrevLoc, diag::note_previous_definition);
1157 if (!PDecl->hasDefinition())
1161 PDecl->getLocation(), PDecl->getReferencedProtocols()))
1172 Decl *
const *ProtoRefs,
1173 unsigned NumProtoRefs,
1179 assert(ProtocolName &&
"Missing protocol identifier");
1185 Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName;
1186 Diag(Def->getLocation(), diag::note_previous_definition);
1193 ProtocolLoc, AtProtoInterfaceLoc,
1195 PDecl->startDefinition();
1203 ProtocolName, ProtocolLoc, PrevDecl->
getLocation(), PList);
1208 ProtocolLoc, AtProtoInterfaceLoc,
1212 PDecl->startDefinition();
1223 if (!err && NumProtoRefs ) {
1226 NumProtoRefs, ProtoLocs);
1238 UndefinedProtocol = PDecl;
1244 UndefinedProtocol = PI;
1271 Diag(Pair.second, diag::err_undeclared_protocol) << Pair.first;
1280 if (!ForObjCContainer) {
1289 if (WarnOnDeclarations &&
1291 Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first;
1292 Diag(UndefinedProtocol->
getLocation(), diag::note_protocol_decl_undefined)
1293 << UndefinedProtocol;
1295 Protocols.push_back(PDecl);
1306 ObjCTypeArgOrProtocolValidatorCCC(
ASTContext &context,
1308 :
Context(context), LookupKind(lookupKind) { }
1310 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
1324 if (isa<RecordDecl>(typeDecl) && !Context.
getLangOpts().CPlusPlus)
1330 if (
type->isObjCObjectPointerType() ||
1331 type->isBlockPointerType() ||
1332 type->isDependentType() ||
1333 type->isObjCObjectType())
1356 bool SelectProtocolFirst) {
1357 Diag(TypeArgLoc, diag::err_objc_type_args_and_protocols)
1358 << SelectProtocolFirst << TypeArgId << ProtocolId
1375 bool warnOnIncompleteProtocols) {
1378 unsigned numProtocolsResolved = 0;
1379 auto resolvedAsProtocols = [&] {
1380 assert(numProtocolsResolved == identifiers.size() &&
"Unresolved protocols");
1387 bool allAreTypeNames =
false;
1391 baseClass = objcObjectType->getInterface();
1393 if (
auto typeParams = baseClass->getTypeParamList()) {
1394 if (typeParams->size() == numProtocolsResolved) {
1396 allAreTypeNames =
true;
1403 for (
unsigned i = 0, n = protocols.size(); i != n; ++i) {
1408 if (!warnOnIncompleteProtocols) {
1420 if (warnOnIncompleteProtocols &&
1422 Diag(identifierLocs[i], diag::warn_undef_protocolref)
1431 if (allAreTypeNames) {
1434 if (isa<ObjCInterfaceDecl>(
decl)) {
1436 firstClassNameLoc = identifierLocs[i];
1437 }
else if (!isa<TypeDecl>(
decl)) {
1439 allAreTypeNames =
false;
1442 allAreTypeNames =
false;
1451 if (allAreTypeNames && firstClassNameLoc.
isValid()) {
1452 llvm::SmallPtrSet<ObjCProtocolDecl*, 8> knownProtocols;
1454 bool allProtocolsDeclared =
true;
1455 for (
auto proto : protocols) {
1456 if (knownProtocols.count(static_cast<ObjCProtocolDecl *>(proto)) == 0) {
1457 allProtocolsDeclared =
false;
1462 if (allProtocolsDeclared) {
1463 Diag(firstClassNameLoc, diag::warn_objc_redundant_qualified_class_type)
1464 << baseClass->getDeclName() <<
SourceRange(lAngleLoc, rAngleLoc)
1470 protocolLAngleLoc = lAngleLoc;
1471 protocolRAngleLoc = rAngleLoc;
1472 assert(protocols.size() == identifierLocs.size());
1476 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1478 protocols.push_back(proto);
1480 ++numProtocolsResolved;
1484 if (numProtocolsResolved == identifiers.size())
1485 return resolvedAsProtocols();
1491 typedef llvm::PointerUnion<TypeDecl *, ObjCInterfaceDecl *> TypeOrClassDecl;
1493 unsigned numTypeDeclsResolved = 0;
1494 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1498 typeDecls.push_back(TypeOrClassDecl());
1502 if (
auto typeDecl = dyn_cast<TypeDecl>(decl)) {
1503 typeDecls.push_back(typeDecl);
1504 ++numTypeDeclsResolved;
1508 if (
auto objcClass = dyn_cast<ObjCInterfaceDecl>(decl)) {
1509 typeDecls.push_back(objcClass);
1510 ++numTypeDeclsResolved;
1514 typeDecls.push_back(TypeOrClassDecl());
1521 auto resolveTypeReference = [&](TypeOrClassDecl typeDecl,
SourceLocation loc)
1525 const char* prevSpec;
1528 if (
auto *actualTypeDecl = typeDecl.dyn_cast<
TypeDecl *>())
1558 Diag(loc, diag::err_objc_type_arg_missing_star)
1569 auto resolvedAsTypeDecls = [&] {
1573 assert(numTypeDeclsResolved == identifiers.size() &&
"Unresolved type decl");
1575 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1577 TypeResult type = resolveTypeReference(typeDecls[i], identifierLocs[i]);
1583 typeArgs.push_back(type.
get());
1586 typeArgsLAngleLoc = lAngleLoc;
1587 typeArgsRAngleLoc = rAngleLoc;
1592 if (numTypeDeclsResolved == identifiers.size())
1593 return resolvedAsTypeDecls();
1599 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1602 if (protocols[i] || typeDecls[i]) {
1608 if (protocols[i] && typeDecls[i])
1631 identifiers[i], identifierLocs[i],
1632 protocols[i] !=
nullptr);
1643 llvm::make_unique<ObjCTypeArgOrProtocolValidatorCCC>(
Context,
1650 PDiag(diag::err_undeclared_protocol_suggest)
1653 protocols[i] = proto;
1654 ++numProtocolsResolved;
1661 PDiag(diag::err_unknown_typename_suggest)
1664 typeDecls[i] = typeDecl;
1665 ++numTypeDeclsResolved;
1672 PDiag(diag::err_unknown_type_or_class_name_suggest)
1673 << identifiers[i] <<
true);
1675 typeDecls[i] = objcClass;
1676 ++numTypeDeclsResolved;
1682 Diag(identifierLocs[i],
1683 (lookupKind ==
LookupAnyName ? diag::err_objc_type_arg_missing
1685 : diag::err_unknown_typename))
1694 if (numProtocolsResolved == identifiers.size())
1695 return resolvedAsProtocols();
1698 assert(numTypeDeclsResolved == identifiers.size() &&
"Not all types?");
1699 return resolvedAsTypeDecls();
1710 llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
1711 for (
auto *MD : ID->
methods())
1712 MethodMap[MD->getSelector()] = MD;
1714 if (MethodMap.empty())
1716 for (
const auto *Method : CAT->
methods()) {
1717 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
1721 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
1722 << Method->getDeclName();
1740 IdentPair.second, AtProtocolLoc,
1753 DeclsInGroup.push_back(PDecl);
1765 Decl *
const *ProtoRefs,
1766 unsigned NumProtoRefs,
1777 diag::err_category_forward_interface,
1778 CategoryName ==
nullptr)) {
1783 ClassLoc, CategoryLoc, CategoryName,
1784 IDecl, typeParamList);
1789 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1794 Diag(ClassLoc, diag::err_class_extension_after_impl) << ClassName;
1796 diag::note_implementation_declared);
1804 Diag(CategoryLoc, diag::warn_dup_category_def)
1805 << ClassName << CategoryName;
1806 Diag(
Previous->getLocation(), diag::note_previous_definition);
1811 if (typeParamList) {
1816 : TypeParamListContext::Extension))
1817 typeParamList =
nullptr;
1820 diag::err_objc_parameterized_category_nonclass)
1821 << (CategoryName !=
nullptr)
1825 typeParamList =
nullptr;
1830 ClassLoc, CategoryLoc, CategoryName, IDecl,
1837 NumProtoRefs, ProtoLocs);
1878 ClassLoc, AtCatImplLoc, CatLoc);
1881 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1884 diag::err_undef_interface)) {
1893 if (IDecl && IDecl->
hasAttr<ObjCRuntimeVisibleAttr>()) {
1894 Diag(ClassLoc, diag::err_objc_runtime_visible_category)
1901 Diag(ClassLoc, diag::err_dup_implementation_category) << ClassName
1904 diag::note_previous_definition);
1929 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1930 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
1932 }
else if ((IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl))) {
1936 diag::warn_undef_interface);
1942 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(),
CTK_NonError);
1948 PDiag(diag::warn_undef_interface_suggest) << ClassName,
1951 Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
1957 if (SuperClassname) {
1961 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1962 Diag(SuperClassLoc, diag::err_redefinition_different_kind)
1966 SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
1970 Diag(SuperClassLoc, diag::err_undef_superclass)
1971 << SuperClassname << ClassName;
1975 Diag(SuperClassLoc, diag::err_conflicting_super_class)
2014 ClassLoc, AtClassImplLoc, SuperClassLoc);
2022 Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
2024 diag::note_previous_definition);
2038 Diag(ClassLoc, diag::err_objc_runtime_visible_subclass)
2049 DeclsInGroup.reserve(Decls.size() + 1);
2051 for (
unsigned i = 0, e = Decls.size(); i != e; ++i) {
2052 Decl *Dcl = Decls[i];
2057 DeclsInGroup.push_back(Dcl);
2060 DeclsInGroup.push_back(ObjCImpDecl);
2068 assert(ImpDecl &&
"missing implementation decl");
2078 for (
unsigned i = 0, e = numIvars; i != e; ++i) {
2090 assert(ivars &&
"missing @implementation ivars");
2094 for (
unsigned i = 0; i < numIvars; i++) {
2099 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2107 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
2124 for (; numIvars > 0 && IVI != IVE; ++IVI) {
2127 assert (ImplIvar &&
"missing implementation ivar");
2128 assert (ClsIvar &&
"missing class ivar");
2140 diag::err_conflicting_ivar_bitwidth) << ImplIvar->
getIdentifier();
2142 diag::note_previous_definition);
2154 Diag(ivars[j]->getLocation(), diag::err_inconsistent_ivar_count);
2155 else if (IVI != IVE)
2156 Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
2161 bool &IncompleteImpl,
2191 S.
Diag(MethodLoc, diag::note_method_declared_at) << method;
2269 (y & ~
Decl::OBJC_TQ_CSNullability);
2275 bool IsProtocolMethodDecl,
2276 bool IsOverridingMode,
2278 if (IsProtocolMethodDecl &&
2284 ? diag::warn_conflicting_overriding_ret_type_modifiers
2285 : diag::warn_conflicting_ret_type_modifiers))
2294 if (Warn && IsOverridingMode &&
2299 auto nullabilityMethodImpl =
2301 auto nullabilityMethodDecl =
2304 diag::warn_conflicting_nullability_attr_overriding_ret_types)
2306 nullabilityMethodImpl,
2310 nullabilityMethodDecl,
2323 IsOverridingMode ? diag::warn_conflicting_overriding_ret_types
2324 : diag::warn_conflicting_ret_types;
2340 IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types
2341 : diag::warn_non_covariant_ret_types;
2350 ? diag::note_previous_declaration
2351 : diag::note_previous_definition)
2361 bool IsProtocolMethodDecl,
2362 bool IsOverridingMode,
2364 if (IsProtocolMethodDecl &&
2368 if (IsOverridingMode)
2370 diag::warn_conflicting_overriding_param_modifiers)
2374 diag::warn_conflicting_param_modifiers)
2386 if (Warn && IsOverridingMode &&
2390 diag::warn_conflicting_nullability_attr_overriding_param_types)
2407 IsOverridingMode ? diag::warn_conflicting_overriding_param_types
2408 : diag::warn_conflicting_param_types;
2424 IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types
2425 : diag::warn_non_contravariant_param_types;
2431 << MethodImpl->
getDeclName() << IfaceTy << ImplTy;
2433 (IsOverridingMode ? diag::note_previous_declaration
2434 : diag::note_previous_definition))
2445 if (implFamily == declFamily)
return false;
2457 unsigned errorID = diag::err_arc_lost_method_convention;
2458 unsigned noteID = diag::note_arc_lost_method_convention;
2461 family = implFamily;
2462 errorID = diag::err_arc_gained_method_convention;
2463 noteID = diag::note_arc_gained_method_convention;
2467 enum FamilySelector {
2468 F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new
2470 FamilySelector familySelector = FamilySelector();
2473 case OMF_None: llvm_unreachable(
"logic error, no method convention");
2487 case OMF_init: familySelector = F_init;
break;
2488 case OMF_alloc: familySelector = F_alloc;
break;
2489 case OMF_copy: familySelector = F_copy;
break;
2491 case OMF_new: familySelector = F_new;
break;
2494 enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn };
2495 ReasonSelector reasonSelector;
2500 reasonSelector = R_UnrelatedReturn;
2502 reasonSelector = R_NonObjectReturn;
2505 S.
Diag(impl->
getLocation(), errorID) <<
int(familySelector) << int(reasonSelector);
2506 S.
Diag(decl->
getLocation(), noteID) <<
int(familySelector) << int(reasonSelector);
2513 bool IsProtocolMethodDecl) {
2519 IsProtocolMethodDecl,
false,
2525 IM != EM && IF != EF; ++IM, ++IF) {
2527 IsProtocolMethodDecl,
false,
true);
2532 diag::warn_conflicting_variadic);
2539 bool IsProtocolMethodDecl) {
2542 IsProtocolMethodDecl,
true,
2548 IM != EM && IF != EF; ++IM, ++IF) {
2550 IsProtocolMethodDecl,
true,
true);
2555 diag::warn_conflicting_overriding_variadic);
2564 bool IsProtocolMethodDecl) {
2572 if (MethodDecl->
hasAttr<UnavailableAttr>() ||
2573 MethodDecl->
hasAttr<DeprecatedAttr>())
2577 IsProtocolMethodDecl,
false,
false);
2582 IM != EM && IF != EF; ++IM, ++IF) {
2585 IsProtocolMethodDecl,
false,
false);
2597 diag::warn_category_method_impl_match);
2614 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>())
2616 for (
const auto *PI : PDecl->
protocols())
2639 bool& IncompleteImpl,
2647 assert (IDecl &&
"CheckProtocolMethodDefs - IDecl is null");
2663 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>()) {
2664 if (!ProtocolsExplictImpl) {
2669 ProtocolsExplictImpl->end())
2687 if (InsMap.count(fISelector))
2707 !method->isPropertyAccessor() &&
2708 !InsMap.count(method->getSelector()) &&
2724 IDecl->lookupMethod(method->getSelector(),
2728 if (C || MethodInClass->isPropertyAccessor())
2730 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2740 !ClsMap.count(method->getSelector()) &&
2747 if (C && IDecl->lookupMethod(method->getSelector(),
2753 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2762 CDecl, ProtocolsExplictImpl);
2774 bool &IncompleteImpl,
2775 bool ImmediateClass,
2776 bool WarnCategoryMethodImpl) {
2780 if (!InsMapSeen.insert(I->getSelector()).second)
2782 if (!I->isPropertyAccessor() &&
2783 !InsMap.count(I->getSelector())) {
2786 diag::warn_undef_method_impl);
2792 "Expected to find the method through lookup as well");
2794 if (ImpMethodDecl) {
2795 if (!WarnCategoryMethodImpl)
2797 isa<ObjCProtocolDecl>(CDecl));
2798 else if (!I->isPropertyAccessor())
2807 if (!ClsMapSeen.insert(I->getSelector()).second)
2809 if (!I->isPropertyAccessor() &&
2810 !ClsMap.count(I->getSelector())) {
2813 diag::warn_undef_method_impl);
2818 "Expected to find the method through lookup as well");
2820 if (ImpMethodDecl) {
2821 if (!WarnCategoryMethodImpl)
2823 isa<ObjCProtocolDecl>(CDecl));
2824 else if (!I->isPropertyAccessor())
2833 for (
auto *PI : PD->protocols())
2835 IMPDecl, PI, IncompleteImpl,
false,
2836 WarnCategoryMethodImpl);
2843 if (!WarnCategoryMethodImpl) {
2844 for (
auto *Cat : I->visible_categories())
2846 IMPDecl, Cat, IncompleteImpl,
2847 ImmediateClass && Cat->IsClassExtension(),
2848 WarnCategoryMethodImpl);
2851 for (
auto *Ext : I->visible_extensions())
2853 IMPDecl, Ext, IncompleteImpl,
false,
2854 WarnCategoryMethodImpl);
2858 for (
auto *PI : I->all_referenced_protocols())
2860 IMPDecl, PI, IncompleteImpl,
false,
2861 WarnCategoryMethodImpl);
2865 if (!WarnCategoryMethodImpl && I->getSuperClass())
2868 I->getSuperClass(), IncompleteImpl,
false);
2899 if (SuperIDecl && SuperIDecl->
lookupMethod(Sel,
false))
2903 if (InsMap.empty() && ClsMap.empty())
2907 bool IncompleteImpl =
false;
2910 IncompleteImpl,
false,
2916 bool IncompleteImpl) {
2921 InsMap.insert(I->getSelector());
2929 const auto *
P = PImpl->getPropertyDecl();
2932 InsMap.insert(
P->getGetterName());
2933 if (!
P->getSetterName().isNull())
2934 InsMap.insert(
P->getSetterName());
2941 bool SynthesizeProperties =
LangOpts.ObjCDefaultSynthProperties &&
2943 !IDecl->isObjCRequiresPropertyDefs();
2952 ClsMap.insert(I->getSelector());
2959 IncompleteImpl,
true);
2964 dyn_cast<ObjCCategoryImplDecl>(IMPDecl))
2975 for (
auto *PI : I->all_referenced_protocols())
2977 InsMap, ClsMap, I, ExplicitImplProtocols);
2981 if (!
C->IsClassExtension()) {
2982 for (
auto *
P :
C->protocols())
2984 IncompleteImpl, InsMap, ClsMap, CDecl,
2985 ExplicitImplProtocols);
2990 llvm_unreachable(
"invalid ObjCContainerDecl type.");
3000 for (
unsigned i = 0; i != NumElts; ++i) {
3005 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
3015 Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
3023 Diag(AtClassLoc, diag::warn_forward_class_redefinition)
3033 = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
3055 if (PrevIDecl && TypeParams) {
3059 *
this, PrevTypeParams, TypeParams,
3060 TypeParamListContext::ForwardDeclaration)) {
3061 TypeParams =
nullptr;
3065 Diag(IdentLocs[i], diag::err_objc_parameterized_forward_class)
3068 Diag(Def->getLocation(), diag::note_defined_here)
3071 TypeParams =
nullptr;
3077 ClassName, TypeParams, PrevIDecl,
3083 DeclsInGroup.push_back(IDecl);
3091 const Type *left,
const Type *right);
3100 if (left == right)
return true;
3123 if (isa<VectorType>(left))
return isa<VectorType>(right);
3124 if (isa<VectorType>(right))
return false;
3147 return (leftSK == rightSK);
3153 assert(lt && rt && lt != rt);
3155 if (!isa<RecordType>(lt) || !isa<RecordType>(rt))
return false;
3156 RecordDecl *left = cast<RecordType>(lt)->getDecl();
3157 RecordDecl *right = cast<RecordType>(rt)->getDecl();
3163 if ((isa<CXXRecordDecl>(left) && !cast<CXXRecordDecl>(left)->isPOD()) ||
3164 (isa<CXXRecordDecl>(right) && !cast<CXXRecordDecl>(right)->isPOD()))
3179 for (; li != le && ri != re; ++li, ++ri) {
3180 if (!
matchTypes(Context, strategy, li->getType(), ri->getType()))
3183 return (li == le && ri == re);
3201 (left->
hasAttr<NSReturnsRetainedAttr>()
3202 != right->
hasAttr<NSReturnsRetainedAttr>() ||
3203 left->
hasAttr<NSConsumesSelfAttr>()
3204 != right->
hasAttr<NSConsumesSelfAttr>()))
3211 for (; li != le && ri != re; ++li, ++ri) {
3212 assert(ri != right->
param_end() &&
"Param mismatch");
3215 if (!
matchTypes(Context, strategy, lparm->getType(), rparm->getType()))
3219 lparm->hasAttr<NSConsumedAttr>() != rparm->hasAttr<NSConsumedAttr>())
3228 auto *MethodInListProtocol =
3232 if ((MethodProtocol && !MethodInListProtocol) ||
3233 (!MethodProtocol && MethodInListProtocol))
3236 if (MethodProtocol && MethodInListProtocol)
3242 return MethodInterface == MethodInListInterface;
3251 if (!CD->IsClassExtension() && List->
getBits() < 2)
3265 for (; List; Previous = List, List = List->
getNext()) {
3282 if (!SameDeclaration ||
3288 List->setHasMoreThanOneDecl(
true);
3294 ListWithSameDeclaration = List;
3297 !ListWithSameDeclaration &&
3299 ListWithSameDeclaration = List;
3313 List->setHasMoreThanOneDecl(
true);
3320 List->setMethod(Method);
3326 List->setMethod(Method);
3337 if (ListWithSameDeclaration) {
3340 ListWithSameDeclaration->
setMethod(Method);
3341 ListWithSameDeclaration->
setNext(List);
3351 assert(ExternalSource &&
"We need an external AST source");
3352 ExternalSource->ReadMethodPool(Sel);
3356 if (!ExternalSource)
3358 ExternalSource->updateOutOfDateSelector(Sel);
3361 void Sema::AddMethodToGlobalPool(
ObjCMethodDecl *Method,
bool impl,
3377 ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
3411 assert(BoundInterface &&
"unexpected object type!");
3416 if (MethodProtocol) {
3426 return MethodInterface == BoundInterface ||
3427 MethodInterface->isSuperClassOf(BoundInterface) ||
3428 BoundInterface->isSuperClassOf(MethodInterface);
3430 llvm_unreachable(
"unknow method context");
3437 bool InstanceFirst,
bool CheckTheOther,
3442 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3450 if (M->getMethod() && !M->getMethod()->isHidden()) {
3452 Methods.push_back(M->getMethod());
3456 if (!Methods.empty())
3457 return Methods.size() > 1;
3466 if (M->getMethod() && !M->getMethod()->isHidden()) {
3468 Methods.push_back(M->getMethod());
3471 return Methods.size() > 1;
3479 FilteredMethods.push_back(BestMethod);
3481 for (
auto *M : Methods)
3482 if (M != BestMethod && !M->
hasAttr<UnavailableAttr>())
3483 FilteredMethods.push_back(M);
3485 if (FilteredMethods.size() > 1)
3489 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3500 bool receiverIdOrClass,
3505 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3510 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
3513 if (M->getMethod() && !M->getMethod()->isHidden())
3514 return M->getMethod();
3521 bool receiverIdOrClass) {
3523 bool issueDiagnostic =
false, issueError =
false;
3527 bool strictSelectorMatch =
3528 receiverIdOrClass &&
3530 if (strictSelectorMatch) {
3531 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3533 issueDiagnostic =
true;
3542 if (!strictSelectorMatch ||
3543 (issueDiagnostic &&
getLangOpts().ObjCAutoRefCount))
3544 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3548 issueDiagnostic =
true;
3555 if (issueDiagnostic) {
3557 Diag(R.
getBegin(), diag::err_arc_multiple_method_decl) << Sel << R;
3558 else if (strictSelectorMatch)
3559 Diag(R.
getBegin(), diag::warn_strict_multiple_method_decl) << Sel << R;
3561 Diag(R.
getBegin(), diag::warn_multiple_method_decl) << Sel << R;
3563 Diag(Methods[0]->getLocStart(),
3564 issueError ? diag::note_possibility : diag::note_using)
3565 << Methods[0]->getSourceRange();
3566 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3567 Diag(Methods[I]->getLocStart(), diag::note_also_found)
3568 << Methods[I]->getSourceRange();
3574 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3580 Method = Method->getNext())
3581 if (Method->getMethod() &&
3584 return Method->getMethod();
3587 Method = Method->getNext())
3588 if (Method->getMethod() &&
3591 return Method->getMethod();
3599 const unsigned MaxEditDistance = 1;
3600 unsigned BestEditDistance = MaxEditDistance + 1;
3603 unsigned MinPossibleEditDistance =
abs((
int)MethodName.size() - (int)Typo.size());
3604 if (MinPossibleEditDistance > 0 &&
3605 Typo.size() / MinPossibleEditDistance < 1)
3607 unsigned EditDistance = Typo.edit_distance(MethodName,
true, MaxEditDistance);
3608 if (EditDistance > MaxEditDistance)
3610 if (EditDistance == BestEditDistance)
3611 BestMethod.push_back(Method);
3612 else if (EditDistance < BestEditDistance) {
3614 BestMethod.push_back(Method);
3633 bool ObjectIsId =
true, ObjectIsClass =
true;
3635 ObjectIsId = ObjectIsClass =
false;
3640 ObjectType =
QualType(ObjCPtr->getInterfaceType(), 0);
3641 ObjectIsId = ObjectIsClass =
false;
3644 ObjectIsClass =
false;
3650 for (GlobalMethodPool::iterator b =
MethodPool.begin(),
3654 if (M->getMethod() &&
3655 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3656 (M->getMethod()->getSelector() != Sel)) {
3658 Methods.push_back(M->getMethod());
3659 else if (!ObjectIsClass &&
3662 Methods.push_back(M->getMethod());
3666 if (M->getMethod() &&
3667 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3668 (M->getMethod()->getSelector() != Sel)) {
3670 Methods.push_back(M->getMethod());
3671 else if (!ObjectIsId &&
3674 Methods.push_back(M->getMethod());
3679 for (
unsigned i = 0, e = Methods.size(); i < e; i++) {
3683 return (SelectedMethods.size() == 1) ? SelectedMethods[0] :
nullptr;
3693 for (
auto *Ivar : ID->
ivars()) {
3694 if (Ivar->isInvalidDecl())
3699 Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
3701 Ivar->setInvalidDecl();
3713 if (ivar->isInvalidDecl())
continue;
3716 S.
Diag(ivar->getLocation(), diag::err_arc_weak_disabled);
3718 S.
Diag(ivar->getLocation(), diag::err_arc_weak_no_runtime);
3732 if (ivar->isInvalidDecl())
3738 S.
Diag(ivar->getLocation(), diag::err_flexible_array_arc_retainable);
3739 ivar->setInvalidDecl();
3746 case Decl::ObjCInterface:
3748 case Decl::ObjCProtocol:
3750 case Decl::ObjCCategory:
3751 if (cast<ObjCCategoryDecl>(
CurContext)->IsClassExtension())
3754 case Decl::ObjCImplementation:
3756 case Decl::ObjCCategoryImpl:
3768 return (RecordTy && RecordTy->getDecl()->hasFlexibleArrayMember());
3775 if ((IntfDecl = dyn_cast<ObjCInterfaceDecl>(OCD))) {
3776 Ivars = IntfDecl->
ivars();
3777 }
else if (
auto *ImplDecl = dyn_cast<ObjCImplementationDecl>(OCD)) {
3778 IntfDecl = ImplDecl->getClassInterface();
3779 Ivars = ImplDecl->
ivars();
3780 }
else if (
auto *CategoryDecl = dyn_cast<ObjCCategoryDecl>(OCD)) {
3781 if (CategoryDecl->IsClassExtension()) {
3782 IntfDecl = CategoryDecl->getClassInterface();
3783 Ivars = CategoryDecl->
ivars();
3788 if (!isa<ObjCInterfaceDecl>(OCD)) {
3789 for (
auto ivar : Ivars) {
3791 S.
Diag(ivar->getLocation(), diag::warn_variable_sized_ivar_visibility)
3792 << ivar->getDeclName() << ivar->getType();
3804 if (ivar->isInvalidDecl() || !ivar->getNextIvar())
3807 bool IsInvalidIvar =
false;
3809 S.
Diag(ivar->getLocation(), diag::err_flexible_array_not_at_end)
3810 << ivar->getDeclName() << IvarTy
3812 IsInvalidIvar =
true;
3814 if (RecordTy->getDecl()->hasFlexibleArrayMember()) {
3815 S.
Diag(ivar->getLocation(),
3816 diag::err_objc_variable_sized_type_not_at_end)
3817 << ivar->getDeclName() << IvarTy;
3818 IsInvalidIvar =
true;
3821 if (IsInvalidIvar) {
3822 S.
Diag(ivar->getNextIvar()->getLocation(),
3823 diag::note_next_ivar_declaration)
3824 << ivar->getNextIvar()->getSynthesize();
3825 ivar->setInvalidDecl();
3833 (Ivars.begin() == Ivars.end()) ?
nullptr : *Ivars.begin();
3836 while (SuperClass && SuperClass->
ivar_empty())
3840 std::advance(IvarIter, SuperClass->
ivar_size() - 1);
3844 diag::warn_superclass_variable_sized_type_not_at_end)
3845 << FirstIvar->
getDeclName() << LastIvar->getDeclName()
3846 << LastIvar->getType() << SuperClass->
getDeclName();
3847 S.
Diag(LastIvar->getLocation(), diag::note_entity_declared_at)
3848 << LastIvar->getDeclName();
3860 assert(AtEnd.
isValid() &&
"Invalid location for '@end'");
3863 Decl *ClassDecl = cast<Decl>(OCD);
3865 bool isInterfaceDeclKind =
3866 isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl)
3867 || isa<ObjCProtocolDecl>(ClassDecl);
3868 bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
3871 llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap;
3872 llvm::DenseMap<Selector, const ObjCMethodDecl*> ClsMap;
3874 for (
unsigned i = 0, e = allMethods.size(); i != e; i++ ) {
3876 cast_or_null<ObjCMethodDecl>(allMethods[i]);
3878 if (!Method)
continue;
3884 if ((isInterfaceDeclKind && PrevMethod && !match)
3885 || (checkIdenticalMethods && match)) {
3908 if ((isInterfaceDeclKind && PrevMethod && !match)
3909 || (checkIdenticalMethods && match)) {
3928 if (isa<ObjCInterfaceDecl>(ClassDecl)) {
3935 if (
C->IsClassExtension()) {
3941 if (CDecl->getIdentifier())
3945 for (
auto *I : CDecl->properties())
3947 CDecl->setAtEndRange(AtEnd);
3950 IC->setAtEndRange(AtEnd);
3957 for (
const auto *Ext : IDecl->visible_extensions()) {
3958 for (
const auto *
Property : Ext->instance_properties()) {
3961 = IC->FindPropertyImplDecl(
Property->getIdentifier(),
3963 if (PIDecl->getPropertyImplementation()
3967 for (
const auto *Ext : IDecl->visible_extensions()) {
3969 = Ext->getInstanceMethod(
Property->getGetterName()))
3970 GetterMethod->setPropertyAccessor(
true);
3973 = Ext->getInstanceMethod(
Property->getSetterName()))
3974 SetterMethod->setPropertyAccessor(
true);
3982 if (IDecl->hasDesignatedInitializers())
3987 bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>();
3988 if (IDecl->getSuperClass() ==
nullptr) {
3991 if (!HasRootClassAttr) {
3994 Diag(DeclLoc, diag::warn_objc_root_class_missing)
3995 << IDecl->getIdentifier();
4002 if (NSObjectDecl && NSObjectDecl->getDefinition()) {
4003 Diag(SuperClassLoc, diag::note_objc_needs_superclass)
4006 Diag(SuperClassLoc, diag::note_objc_needs_superclass);
4009 }
else if (HasRootClassAttr) {
4011 Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass);
4019 if (IDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4020 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4021 Diag(IC->getLocation(), diag::err_restricted_superclass_mismatch);
4022 Diag(Super->getLocation(), diag::note_class_declared);
4027 while (IDecl->getSuperClass()) {
4029 IDecl = IDecl->getSuperClass();
4035 dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
4036 CatImplClass->setAtEndRange(AtEnd);
4042 = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier())) {
4046 }
else if (
const auto *IntfDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
4048 if (!IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4049 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4050 Diag(IntfDecl->getLocation(), diag::err_restricted_superclass_mismatch);
4051 Diag(Super->getLocation(), diag::note_class_declared);
4056 if (isInterfaceDeclKind) {
4058 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4061 if (
VarDecl *VDecl = dyn_cast<VarDecl>(*I)) {
4062 if (!VDecl->hasExternalStorage())
4063 Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass);
4069 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4072 (*I)->setTopLevelDeclInObjCContainer();
4101 if (ResultObjectType->isObjCIdType() ||
4102 ResultObjectType->isObjCQualifiedIdType())
4107 = ResultObjectType->getInterfaceDecl()) {
4113 if (ResultClass->isSuperClassOf(CurrentClass))
4129 class OverrideSearch {
4133 llvm::SmallPtrSet<ObjCMethodDecl*, 4> Overridden;
4142 Sema::GlobalMethodPool::iterator it = S.
MethodPool.find(selector);
4162 searchFromContainer(container);
4164 searchFromContainer(Interface);
4166 searchFromContainer(container);
4170 typedef llvm::SmallPtrSetImpl<ObjCMethodDecl*>::iterator iterator;
4171 iterator begin()
const {
return Overridden.begin(); }
4172 iterator end()
const {
return Overridden.end(); }
4179 #define OBJCCONTAINER(type, base) \ 4181 searchFrom(cast<type##Decl>(container)); \ 4183 #define ABSTRACT_DECL(expansion) 4184 #define DECL(type, base) \ 4186 #include "clang/AST/DeclNodes.inc" 4187 llvm_unreachable(
"not an ObjC container!");
4260 Overridden.insert(meth);
4270 searchFromContainer(container);
4279 OverrideSearch overrides(*
this, ObjCMethod);
4285 bool hasOverriddenMethodsInBaseOrProtocol =
false;
4286 for (OverrideSearch::iterator
4287 i = overrides.begin(), e = overrides.end(); i != e; ++i) {
4290 if (!hasOverriddenMethodsInBaseOrProtocol) {
4294 hasOverriddenMethodsInBaseOrProtocol =
true;
4304 GlobalMethodPool::iterator It =
4309 unsigned CategCount = List.
getBits();
4310 if (CategCount > 0) {
4313 if (CategCount > 1 ||
4315 OverrideSearch overrides(*
this, overridden);
4316 for (OverrideSearch::iterator
4317 OI= overrides.begin(), OE= overrides.end(); OI!=OE; ++OI) {
4321 hasOverriddenMethodsInBaseOrProtocol =
true;
4343 if (ObjCMethod->
isImplicit() && overridden->isImplicit())
4350 isa<ObjCProtocolDecl>(overridden->getDeclContext()));
4352 if (CurrentClass && overridden->
getDeclContext() != CurrentClass &&
4353 isa<ObjCInterfaceDecl>(overridden->getDeclContext()) &&
4358 PrevE = overridden->param_end();
4359 for (; ParamI != E && PrevI != PrevE; ++ParamI, ++PrevI) {
4360 assert(PrevI != overridden->param_end() &&
"Param mismatch");
4366 Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
4368 Diag(overridden->getLocation(), diag::note_previous_declaration);
4375 ObjCMethod->
setOverriding(hasOverriddenMethodsInBaseOrProtocol);
4385 bool prevUsesCSKeyword) {
4391 if (nullability.hasValue() == prevNullability.hasValue()) {
4397 if (*nullability == *prevNullability)
4401 S.
Diag(loc, diag::err_nullability_conflicting)
4424 if (prevMethod->
hasAttr<ObjCRequiresSuperAttr>() &&
4425 !method->
hasAttr<ObjCRequiresSuperAttr>()) {
4428 ObjCRequiresSuperAttr::CreateImplicit(S.
Context,
4445 unsigned numPrevParams = prevMethod->
param_size();
4446 for (
unsigned i = 0, n =
std::min(numParams, numPrevParams); i != n; ++i) {
4466 llvm::Triple::x86 &&
4467 "x86-specific check invoked for a different target");
4471 if (
P->getType()->isVectorType()) {
4472 Loc =
P->getLocStart();
4477 if (Loc.isInvalid()) {
4489 if (Triple.getOS() == llvm::Triple::IOS)
4491 else if (Triple.isMacOSX())
4498 SemaRef.
Diag(Loc, diag::err_objc_method_unsupported_param_ret_type)
4501 << (Triple.isMacOSX() ?
"macOS 10.11" :
"iOS 9");
4516 bool isVariadic,
bool MethodDefinition) {
4519 Diag(MethodLoc, diag::err_missing_method_context);
4523 Decl *ClassDecl = cast<Decl>(OCD);
4526 bool HasRelatedResultType =
false;
4534 QualType bareResultType = resultDeclType;
4539 Diag(MethodLoc, diag::warn_missing_method_return_type)
4544 Context, MethodLoc, EndLoc, Sel, resultDeclType, ReturnTInfo,
CurContext,
4545 MethodType == tok::minus, isVariadic,
4550 HasRelatedResultType);
4554 for (
unsigned i = 0, e = Sel.
getNumArgs(); i != e; ++i) {
4558 if (!ArgInfo[i].
Type) {
4565 LookupResult R(*
this, ArgInfo[i].Name, ArgInfo[i].NameLoc,
4571 Diag(ArgInfo[i].NameLoc,
4572 (MethodDefinition ? diag::warn_method_param_redefinition
4573 : diag::warn_method_param_declaration))
4576 diag::note_previous_declaration);
4585 ArgInfo[i].NameLoc, ArgInfo[i].Name,
4597 if (Param->
hasAttr<BlocksAttr>()) {
4604 Params.push_back(Param);
4607 for (
unsigned i = 0, e = CNumArgs; i != e; ++i) {
4610 if (ArgType.isNull())
4617 Params.push_back(Param);
4620 ObjCMethod->setMethodParams(Context, Params, SelectorLocs);
4621 ObjCMethod->setObjCDeclQualifier(
4630 if (
ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(ClassDecl)) {
4631 if (MethodType == tok::minus) {
4632 PrevMethod = ImpDecl->getInstanceMethod(Sel);
4633 ImpDecl->addInstanceMethod(ObjCMethod);
4635 PrevMethod = ImpDecl->getClassMethod(Sel);
4636 ImpDecl->addClassMethod(ObjCMethod);
4642 if (
auto *IMD = IDecl->lookupMethod(ObjCMethod->getSelector(),
4643 ObjCMethod->isInstanceMethod())) {
4647 if (isa<ObjCCategoryImplDecl>(ImpDecl) && IMD->isOverriding() &&
4648 ObjCMethod->getSelector().getMethodFamily() ==
OMF_dealloc) {
4649 Diag(ObjCMethod->getLocation(), diag::warn_dealloc_in_category)
4650 << ObjCMethod->getDeclName();
4655 cast<DeclContext>(ClassDecl)->addDecl(ObjCMethod);
4660 Diag(ObjCMethod->getLocation(), diag::err_duplicate_method_decl)
4661 << ObjCMethod->getDeclName();
4663 ObjCMethod->setInvalidDecl();
4671 if (!CurrentClass) {
4673 CurrentClass = Cat->getClassInterface();
4674 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(ClassDecl))
4675 CurrentClass = Impl->getClassInterface();
4677 = dyn_cast<ObjCCategoryImplDecl>(ClassDecl))
4678 CurrentClass = CatImpl->getClassInterface();
4686 bool ARCError =
false;
4692 !ObjCMethod->hasRelatedResultType() &&
4693 LangOpts.ObjCInferRelatedResultType) {
4694 bool InferRelatedResultType =
false;
4695 switch (ObjCMethod->getMethodFamily()) {
4709 InferRelatedResultType = ObjCMethod->isClassMethod();
4716 InferRelatedResultType = ObjCMethod->isInstanceMethod();
4720 if (InferRelatedResultType &&
4721 !ObjCMethod->getReturnType()->isObjCIndependentClassType())
4722 ObjCMethod->SetRelatedResultType();
4725 if (MethodDefinition &&
4745 Diag(D->
getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
4759 Diag(DeclStart, diag::err_undef_interface) << ClassName;
4763 Diag(DeclStart, diag::err_atdef_nonfragile_interface);
4771 for (
unsigned i = 0; i < Ivars.size(); i++) {
4779 Decls.push_back(FD);
4784 D != Decls.end(); ++D) {
4788 else if (
RecordDecl *Record = dyn_cast<RecordDecl>(TagD))
4789 Record->addDecl(FD);
4804 Diag(IdLoc, diag::err_arg_with_address_space);
4816 Diag(IdLoc ,diag::err_catch_param_not_objc_type);
4819 Diag(IdLoc, diag::err_illegal_qualifiers_on_catch_parm);
4852 diag::err_invalid_thread)
4886 if (New->
hasAttr<BlocksAttr>())
4899 Ivars.push_back(Iv);
4905 if (ExternalSource) {
4907 ExternalSource->ReadReferencedSelectors(Sels);
4908 for (
unsigned I = 0, N = Sels.size(); I != N; ++I)
4919 Selector Sel = SelectorAndLocation.first;
4922 Diag(Loc, diag::warn_unimplemented_selector) << Sel;
4945 IV->getIdentifier());
4954 class UnusedBackingIvarChecker :
4961 bool InvokedSelfMethod;
4965 : S(S), Method(Method), IvarD(IvarD),
4966 AccessedIvar(
false), InvokedSelfMethod(
false) {
4972 AccessedIvar =
true;
4981 InvokedSelfMethod =
true;
4994 unsigned DIAG = diag::warn_unused_property_backing_ivar;
5004 UnusedBackingIvarChecker Checker(*
this, CurMethod, IV);
5005 Checker.TraverseStmt(CurMethod->getBody());
5006 if (Checker.AccessedIvar)
5013 if (!IV->
isReferenced() || !Checker.InvokedSelfMethod) {
5014 Diag(Loc, DIAG) << IV;
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl *> allMethods=None, ArrayRef< DeclGroupPtrTy > allTUVars=None)
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
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.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
void setStarLoc(SourceLocation Loc)
Represents a version number in the form major[.minor[.subminor[.build]]].
unsigned param_size() const
ObjCInterfaceDecl * getClassInterface()
all_protocol_range all_referenced_protocols() const
ObjCInterfaceDecl * getClassInterface()
void setOverriding(bool isOverriding)
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.
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)
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)
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, AttributeList *attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
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".
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
SourceLocation getLocEnd() const LLVM_READONLY
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. ...
VarDecl - An instance of this class is created to represent 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
SourceLocation getLocStart() const LLVM_READONLY
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
static const NamedDecl * getDefinition(const Decl *D)
ParmVarDecl - Represents a parameter to a function.
The collection of all-type qualifiers we support.
const ObjCInterfaceDecl * getSuperClass() const
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
RecordDecl - Represents a struct/union/class.
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
DeclarationName getDeclName() const
getDeclName - 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 ...
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
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.
bool isObjCIdType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
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.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
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.
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".
TypeDecl - 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.
Present this diagnostic as an error.
Decl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, AttributeList *AttrList)
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)
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, SHOWINSYSHEADER, CATEGORY)
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
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, bool IncludeCXX11Attributes=true)
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
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
SourceLocation getLocStart() const LLVM_READONLY
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.
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.
const FunctionProtoType * T
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.
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.
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
void setDefined(bool isDefined)
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
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.
SourceLocation getLocEnd() const LLVM_READONLY
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.
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
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.
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...
Decl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, AttributeList *AttrList)
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.
Look up any declaration with any name.
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.
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...
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
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)
Returns instance or factory methods in global method pool for given selector.
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...
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
SourceLocation getLocStart() const LLVM_READONLY
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...
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, AttributeList *AttrList)
QualType getUnderlyingType() const
const ObjCProtocolList & getReferencedProtocols() const
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
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).
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple()) const
Determine the availability of the given declaration.
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.
void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc)
This allows the client to specify that certain warnings are ignored.
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...
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.
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.
Captures information about "declaration specifiers".
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
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 SetRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
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...
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, AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
SourceManager & getSourceManager() const
bool isInlineSpecified() const
a linked list of methods with the same selector name but different signatures.
std::pair< ObjCMethodList, ObjCMethodList > GlobalMethods
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.
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)
NamedDecl - This represents a decl with a name.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
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.
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
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'.
AttributeList - Represents a syntactic attribute.
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...