28 #include "llvm/ADT/DenseMap.h" 29 #include "llvm/ADT/DenseSet.h" 31 using namespace clang;
61 assert(resultClass &&
"unexpected object type!");
66 if (receiverTypeIfCall.
isNull() &&
76 if (receiverTypeIfCall.
isNull())
83 if (!receiverClass)
return false;
86 assert(receiverClass &&
"method not associated with a class!");
102 UnavailableAttr::IR_ARCInitReturnsUnrelated, loc));
107 Diag(loc, diag::err_arc_init_method_unrelated_result_type);
116 if (OldD->
hasAttr<NoEscapeAttr>() && !NewD->
hasAttr<NoEscapeAttr>()) {
117 S.
Diag(NewD->
getLocation(), diag::warn_overriding_method_missing_noescape);
153 CurrentClass = Cat->getClassInterface();
154 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(DC))
155 CurrentClass = Impl->getClassInterface();
157 = dyn_cast<ObjCCategoryImplDecl>(DC))
158 CurrentClass = CatImpl->getClassInterface();
163 diag::warn_related_result_type_compatibility_class)
169 diag::warn_related_result_type_compatibility_protocol)
176 diag::note_related_result_type_family)
181 diag::note_related_result_type_overridden);
184 if ((NewMethod->
hasAttr<NSReturnsRetainedAttr>() !=
185 Overridden->
hasAttr<NSReturnsRetainedAttr>())) {
188 ? diag::err_nsreturns_retained_attribute_mismatch
189 : diag::warn_nsreturns_retained_attribute_mismatch)
193 if ((NewMethod->
hasAttr<NSReturnsNotRetainedAttr>() !=
194 Overridden->
hasAttr<NSReturnsNotRetainedAttr>())) {
197 ? diag::err_nsreturns_retained_attribute_mismatch
198 : diag::warn_nsreturns_retained_attribute_mismatch)
207 ni != ne && oi != oe; ++ni, ++oi) {
210 if (newDecl->
hasAttr<NSConsumedAttr>() !=
211 oldDecl->
hasAttr<NSConsumedAttr>()) {
214 ? diag::err_nsconsumed_attribute_mismatch
215 : diag::warn_nsconsumed_attribute_mismatch);
263 if (method->
hasAttr<NSReturnsRetainedAttr>())
271 if (method->
hasAttr<NSReturnsRetainedAttr>() ||
272 method->
hasAttr<NSReturnsNotRetainedAttr>() ||
273 method->
hasAttr<NSReturnsAutoreleasedAttr>())
286 bool IsCategory =
false;
287 StringRef RealizedPlatform;
289 nullptr, VersionTuple(),
292 if (isa<ObjCMethodDecl>(ND)) {
295 if (RealizedPlatform.empty())
299 if (RealizedPlatform.endswith(
"_app_extension"))
301 S.
Diag(ImplLoc, diag::warn_unavailable_def);
306 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND)) {
307 if (!CD->getClassInterface()->isDeprecated())
309 ND = CD->getClassInterface();
314 S.
Diag(ImplLoc, diag::warn_deprecated_def)
315 << (isa<ObjCMethodDecl>(ND)
317 : isa<ObjCCategoryDecl>(ND) || IsCategory ? 2
319 if (isa<ObjCMethodDecl>(ND))
324 << (isa<ObjCCategoryDecl>(ND) ?
"category" :
"class");
374 diag::err_func_def_incomplete_result))
396 if (!Param->isInvalidDecl() &&
399 Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
402 if (Param->getIdentifier())
445 ImplDeclOfMethodDecl = OID->getImplementation();
446 else if (
ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContDeclOfMethodDecl)) {
447 if (CD->IsClassExtension()) {
449 ImplDeclOfMethodDecl = OID->getImplementation();
451 ImplDeclOfMethodDecl = CD->getImplementation();
455 if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
463 IC->getSuperClass() !=
nullptr;
464 }
else if (IC->hasDesignatedInitializers()) {
490 (SuperMethod && SuperMethod->
hasAttr<ObjCRequiresSuperAttr>());
503 ObjCInterfaceValidatorCCC() : CurrentIDecl(
nullptr) {}
505 : CurrentIDecl(IDecl) {}
507 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
521 unsigned NumProtoRefs,
526 for (
unsigned i = 0; i < NumProtoRefs; ++i) {
554 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(IDecl),
557 << SuperName << ClassName);
563 Diag(SuperLoc, diag::err_recursive_superclass)
564 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
568 dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
572 if (SuperClassDecl) {
577 if (PrevDecl && !SuperClassDecl) {
581 dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
582 QualType T = TDecl->getUnderlyingType();
602 if (!SuperClassDecl) {
603 Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
608 if (!dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
610 Diag(SuperLoc, diag::err_undef_superclass)
611 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
614 diag::err_forward_superclass,
617 SourceRange(AtInterfaceLoc, ClassLoc))) {
618 SuperClassDecl =
nullptr;
623 if (SuperClassType.isNull()) {
624 assert(!SuperClassDecl &&
"Failed to set SuperClassType?");
630 if (!SuperTypeArgs.empty()) {
638 SuperTypeArgsRange.
getEnd(),
650 if (!SuperClassTInfo) {
670 if (parsedTypeBound) {
681 diag::err_objc_type_param_bound_missing_pointer)
682 << typeBound << paramName
701 diag::err_objc_type_param_bound_nonobject)
702 << typeBound << paramName;
705 typeBoundInfo =
nullptr;
714 bool diagnosed =
false;
718 rangeToRemove = attr.getLocalSourceRange();
719 if (attr.getTypePtr()->getImmediateNullability()) {
720 Diag(attr.getLocStart(),
721 diag::err_objc_type_param_bound_explicit_nullability)
722 << paramName << typeBound
732 diag::err_objc_type_param_bound_qualified)
742 if (!quals.
empty()) {
752 if (!typeBoundInfo) {
759 index, paramLoc, paramName, colonLoc,
770 reinterpret_cast<ObjCTypeParamDecl * const *>(typeParamsIn.data()),
771 typeParamsIn.size());
777 llvm::SmallDenseMap<IdentifierInfo *, ObjCTypeParamDecl *> knownParams;
778 for (
auto typeParam : typeParams) {
779 auto known = knownParams.find(typeParam->getIdentifier());
780 if (known != knownParams.end()) {
781 Diag(typeParam->getLocation(), diag::err_objc_type_param_redecl)
782 << typeParam->getIdentifier()
785 typeParam->setInvalidDecl();
787 knownParams.insert(std::make_pair(typeParam->getIdentifier(), typeParam));
799 for (
auto typeParam : *typeParamList) {
800 if (!typeParam->isInvalidDecl()) {
826 if (prevTypeParams->
size() != newTypeParams->
size()) {
828 if (newTypeParams->
size() > prevTypeParams->
size()) {
834 S.
Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
835 <<
static_cast<unsigned>(newContext)
836 << (newTypeParams->
size() > prevTypeParams->
size())
837 << prevTypeParams->
size()
838 << newTypeParams->
size();
844 for (
unsigned i = 0, n = prevTypeParams->
size(); i != n; ++i) {
851 newContext != TypeParamListContext::Definition) {
870 auto diag = S.
Diag(diagLoc,
871 diag::err_objc_type_param_variance_conflict)
872 <<
static_cast<unsigned>(newTypeParam->
getVariance())
874 <<
static_cast<unsigned>(prevTypeParam->
getVariance())
883 StringRef newVarianceStr
890 (newVarianceStr +
" ").str());
917 S.
Diag(newBoundRange.
getBegin(), diag::err_objc_type_param_bound_conflict)
942 if (newContext == TypeParamListContext::ForwardDeclaration ||
943 newContext == TypeParamListContext::Definition) {
951 diag::err_objc_type_param_bound_missing)
954 << (newContext == TypeParamListContext::ForwardDeclaration)
974 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
977 assert(ClassName &&
"Missing class identifier");
984 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
985 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
992 if (PrevIDecl && PrevIDecl->getIdentifier() != ClassName) {
1005 ClassName = PrevIDecl->getIdentifier();
1012 if (typeParamList) {
1016 TypeParamListContext::Definition)) {
1017 typeParamList =
nullptr;
1020 Diag(ClassLoc, diag::err_objc_parameterized_forward_class_first)
1022 Diag(prevTypeParamList->getLAngleLoc(), diag::note_previous_decl)
1027 for (
auto typeParam : *prevTypeParamList) {
1028 clonedTypeParams.push_back(
1032 typeParam->getVariance(),
1034 typeParam->getIndex(),
1036 typeParam->getIdentifier(),
1051 typeParamList, PrevIDecl, ClassLoc);
1055 Diag(AtInterfaceLoc, diag::err_duplicate_class_def)
1056 << PrevIDecl->getDeclName();
1057 Diag(Def->getLocation(), diag::note_previous_definition);
1076 ClassName, ClassLoc,
1077 SuperName, SuperLoc, SuperTypeArgs,
1078 SuperTypeArgsRange);
1086 NumProtoRefs, ProtoLocs);
1110 if (
const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) {
1111 QualType T = TDecl->getUnderlyingType();
1114 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end());
1119 ProtocolLocs.append(OPT->getNumProtocols(), SuperLoc);
1136 Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
1145 dyn_cast_or_null<TypedefNameDecl>(CDeclU)) {
1146 QualType T = TDecl->getUnderlyingType();
1149 ClassName = IDecl->getIdentifier();
1158 Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
1181 E = PList.
end(); I != E; ++I) {
1184 if (PDecl->getIdentifier() == PName) {
1185 Diag(Ploc, diag::err_protocol_has_circular_dependency);
1186 Diag(PrevLoc, diag::note_previous_definition);
1190 if (!PDecl->hasDefinition())
1194 PDecl->getLocation(), PDecl->getReferencedProtocols()))
1208 assert(ProtocolName &&
"Missing protocol identifier");
1214 Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName;
1215 Diag(Def->getLocation(), diag::note_previous_definition);
1222 ProtocolLoc, AtProtoInterfaceLoc,
1229 PDecl->startDefinition();
1237 ProtocolName, ProtocolLoc, PrevDecl->
getLocation(), PList);
1242 ProtocolLoc, AtProtoInterfaceLoc,
1246 PDecl->startDefinition();
1256 if (!err && NumProtoRefs ) {
1259 NumProtoRefs, ProtoLocs);
1271 UndefinedProtocol = PDecl;
1277 UndefinedProtocol = PI;
1304 Diag(Pair.second, diag::err_undeclared_protocol) << Pair.first;
1313 if (!ForObjCContainer) {
1322 if (WarnOnDeclarations &&
1324 Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first;
1325 Diag(UndefinedProtocol->
getLocation(), diag::note_protocol_decl_undefined)
1326 << UndefinedProtocol;
1328 Protocols.push_back(PDecl);
1339 ObjCTypeArgOrProtocolValidatorCCC(
ASTContext &context,
1341 :
Context(context), LookupKind(lookupKind) { }
1343 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
1357 if (isa<RecordDecl>(typeDecl) && !Context.
getLangOpts().CPlusPlus)
1363 if (
type->isObjCObjectPointerType() ||
1364 type->isBlockPointerType() ||
1365 type->isDependentType() ||
1366 type->isObjCObjectType())
1389 bool SelectProtocolFirst) {
1390 Diag(TypeArgLoc, diag::err_objc_type_args_and_protocols)
1391 << SelectProtocolFirst << TypeArgId << ProtocolId
1408 bool warnOnIncompleteProtocols) {
1411 unsigned numProtocolsResolved = 0;
1412 auto resolvedAsProtocols = [&] {
1413 assert(numProtocolsResolved == identifiers.size() &&
"Unresolved protocols");
1420 bool allAreTypeNames =
false;
1424 baseClass = objcObjectType->getInterface();
1426 if (
auto typeParams = baseClass->getTypeParamList()) {
1427 if (typeParams->size() == numProtocolsResolved) {
1429 allAreTypeNames =
true;
1436 for (
unsigned i = 0, n = protocols.size(); i != n; ++i) {
1441 if (!warnOnIncompleteProtocols) {
1453 if (warnOnIncompleteProtocols &&
1455 Diag(identifierLocs[i], diag::warn_undef_protocolref)
1464 if (allAreTypeNames) {
1467 if (isa<ObjCInterfaceDecl>(
decl)) {
1469 firstClassNameLoc = identifierLocs[i];
1470 }
else if (!isa<TypeDecl>(
decl)) {
1472 allAreTypeNames =
false;
1475 allAreTypeNames =
false;
1484 if (allAreTypeNames && firstClassNameLoc.
isValid()) {
1485 llvm::SmallPtrSet<ObjCProtocolDecl*, 8> knownProtocols;
1487 bool allProtocolsDeclared =
true;
1488 for (
auto proto : protocols) {
1489 if (knownProtocols.count(static_cast<ObjCProtocolDecl *>(proto)) == 0) {
1490 allProtocolsDeclared =
false;
1495 if (allProtocolsDeclared) {
1496 Diag(firstClassNameLoc, diag::warn_objc_redundant_qualified_class_type)
1497 << baseClass->getDeclName() <<
SourceRange(lAngleLoc, rAngleLoc)
1503 protocolLAngleLoc = lAngleLoc;
1504 protocolRAngleLoc = rAngleLoc;
1505 assert(protocols.size() == identifierLocs.size());
1509 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1511 protocols.push_back(proto);
1513 ++numProtocolsResolved;
1517 if (numProtocolsResolved == identifiers.size())
1518 return resolvedAsProtocols();
1524 typedef llvm::PointerUnion<TypeDecl *, ObjCInterfaceDecl *> TypeOrClassDecl;
1526 unsigned numTypeDeclsResolved = 0;
1527 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1531 typeDecls.push_back(TypeOrClassDecl());
1535 if (
auto typeDecl = dyn_cast<TypeDecl>(decl)) {
1536 typeDecls.push_back(typeDecl);
1537 ++numTypeDeclsResolved;
1541 if (
auto objcClass = dyn_cast<ObjCInterfaceDecl>(decl)) {
1542 typeDecls.push_back(objcClass);
1543 ++numTypeDeclsResolved;
1547 typeDecls.push_back(TypeOrClassDecl());
1554 auto resolveTypeReference = [&](TypeOrClassDecl typeDecl,
SourceLocation loc)
1558 const char* prevSpec;
1561 if (
auto *actualTypeDecl = typeDecl.dyn_cast<
TypeDecl *>())
1589 Diag(loc, diag::err_objc_type_arg_missing_star)
1600 auto resolvedAsTypeDecls = [&] {
1604 assert(numTypeDeclsResolved == identifiers.size() &&
"Unresolved type decl");
1606 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1608 TypeResult type = resolveTypeReference(typeDecls[i], identifierLocs[i]);
1614 typeArgs.push_back(type.
get());
1617 typeArgsLAngleLoc = lAngleLoc;
1618 typeArgsRAngleLoc = rAngleLoc;
1623 if (numTypeDeclsResolved == identifiers.size())
1624 return resolvedAsTypeDecls();
1630 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1633 if (protocols[i] || typeDecls[i]) {
1639 if (protocols[i] && typeDecls[i])
1662 identifiers[i], identifierLocs[i],
1663 protocols[i] !=
nullptr);
1674 llvm::make_unique<ObjCTypeArgOrProtocolValidatorCCC>(
Context,
1681 PDiag(diag::err_undeclared_protocol_suggest)
1684 protocols[i] = proto;
1685 ++numProtocolsResolved;
1692 PDiag(diag::err_unknown_typename_suggest)
1695 typeDecls[i] = typeDecl;
1696 ++numTypeDeclsResolved;
1703 PDiag(diag::err_unknown_type_or_class_name_suggest)
1704 << identifiers[i] <<
true);
1706 typeDecls[i] = objcClass;
1707 ++numTypeDeclsResolved;
1713 Diag(identifierLocs[i],
1714 (lookupKind ==
LookupAnyName ? diag::err_objc_type_arg_missing
1716 : diag::err_unknown_typename))
1725 if (numProtocolsResolved == identifiers.size())
1726 return resolvedAsProtocols();
1729 assert(numTypeDeclsResolved == identifiers.size() &&
"Not all types?");
1730 return resolvedAsTypeDecls();
1741 llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
1742 for (
auto *MD : ID->
methods())
1743 MethodMap[MD->getSelector()] = MD;
1745 if (MethodMap.empty())
1747 for (
const auto *Method : CAT->
methods()) {
1748 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
1752 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
1753 << Method->getDeclName();
1771 IdentPair.second, AtProtocolLoc,
1783 DeclsInGroup.push_back(PDecl);
1793 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
1803 diag::err_category_forward_interface,
1804 CategoryName ==
nullptr)) {
1809 ClassLoc, CategoryLoc, CategoryName,
1810 IDecl, typeParamList);
1815 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1820 Diag(ClassLoc, diag::err_class_extension_after_impl) << ClassName;
1822 diag::note_implementation_declared);
1830 Diag(CategoryLoc, diag::warn_dup_category_def)
1831 << ClassName << CategoryName;
1832 Diag(
Previous->getLocation(), diag::note_previous_definition);
1837 if (typeParamList) {
1842 : TypeParamListContext::Extension))
1843 typeParamList =
nullptr;
1846 diag::err_objc_parameterized_category_nonclass)
1847 << (CategoryName !=
nullptr)
1851 typeParamList =
nullptr;
1856 ClassLoc, CategoryLoc, CategoryName, IDecl,
1869 NumProtoRefs, ProtoLocs);
1906 ClassLoc, AtCatImplLoc, CatLoc);
1909 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1912 diag::err_undef_interface)) {
1921 if (IDecl && IDecl->
hasAttr<ObjCRuntimeVisibleAttr>()) {
1922 Diag(ClassLoc, diag::err_objc_runtime_visible_category)
1929 Diag(ClassLoc, diag::err_dup_implementation_category) << ClassName
1932 diag::note_previous_definition);
1957 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1958 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
1960 }
else if ((IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl))) {
1964 diag::warn_undef_interface);
1970 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(),
CTK_NonError);
1976 PDiag(diag::warn_undef_interface_suggest) << ClassName,
1979 Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
1985 if (SuperClassname) {
1989 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1990 Diag(SuperClassLoc, diag::err_redefinition_different_kind)
1994 SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
1998 Diag(SuperClassLoc, diag::err_undef_superclass)
1999 << SuperClassname << ClassName;
2003 Diag(SuperClassLoc, diag::err_conflicting_super_class)
2042 ClassLoc, AtClassImplLoc, SuperClassLoc);
2050 Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
2052 diag::note_previous_definition);
2066 Diag(ClassLoc, diag::err_objc_runtime_visible_subclass)
2077 DeclsInGroup.reserve(Decls.size() + 1);
2079 for (
unsigned i = 0, e = Decls.size(); i != e; ++i) {
2080 Decl *Dcl = Decls[i];
2085 DeclsInGroup.push_back(Dcl);
2088 DeclsInGroup.push_back(ObjCImpDecl);
2096 assert(ImpDecl &&
"missing implementation decl");
2106 for (
unsigned i = 0, e = numIvars; i != e; ++i) {
2118 assert(ivars &&
"missing @implementation ivars");
2122 for (
unsigned i = 0; i < numIvars; i++) {
2127 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2135 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
2152 for (; numIvars > 0 && IVI != IVE; ++IVI) {
2155 assert (ImplIvar &&
"missing implementation ivar");
2156 assert (ClsIvar &&
"missing class ivar");
2168 diag::err_conflicting_ivar_bitwidth) << ImplIvar->
getIdentifier();
2170 diag::note_previous_definition);
2182 Diag(ivars[j]->getLocation(), diag::err_inconsistent_ivar_count);
2183 else if (IVI != IVE)
2184 Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
2189 bool &IncompleteImpl,
2211 S.
Diag(MethodLoc, diag::note_method_declared_at) << method;
2289 (y & ~
Decl::OBJC_TQ_CSNullability);
2295 bool IsProtocolMethodDecl,
2296 bool IsOverridingMode,
2298 if (IsProtocolMethodDecl &&
2304 ? diag::warn_conflicting_overriding_ret_type_modifiers
2305 : diag::warn_conflicting_ret_type_modifiers))
2314 if (Warn && IsOverridingMode &&
2319 auto nullabilityMethodImpl =
2321 auto nullabilityMethodDecl =
2324 diag::warn_conflicting_nullability_attr_overriding_ret_types)
2326 nullabilityMethodImpl,
2330 nullabilityMethodDecl,
2343 IsOverridingMode ? diag::warn_conflicting_overriding_ret_types
2344 : diag::warn_conflicting_ret_types;
2360 IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types
2361 : diag::warn_non_covariant_ret_types;
2370 ? diag::note_previous_declaration
2371 : diag::note_previous_definition)
2381 bool IsProtocolMethodDecl,
2382 bool IsOverridingMode,
2384 if (IsProtocolMethodDecl &&
2388 if (IsOverridingMode)
2390 diag::warn_conflicting_overriding_param_modifiers)
2394 diag::warn_conflicting_param_modifiers)
2406 if (Warn && IsOverridingMode &&
2410 diag::warn_conflicting_nullability_attr_overriding_param_types)
2427 IsOverridingMode ? diag::warn_conflicting_overriding_param_types
2428 : diag::warn_conflicting_param_types;
2444 IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types
2445 : diag::warn_non_contravariant_param_types;
2451 << MethodImpl->
getDeclName() << IfaceTy << ImplTy;
2453 (IsOverridingMode ? diag::note_previous_declaration
2454 : diag::note_previous_definition))
2465 if (implFamily == declFamily)
return false;
2477 unsigned errorID = diag::err_arc_lost_method_convention;
2478 unsigned noteID = diag::note_arc_lost_method_convention;
2481 family = implFamily;
2482 errorID = diag::err_arc_gained_method_convention;
2483 noteID = diag::note_arc_gained_method_convention;
2487 enum FamilySelector {
2488 F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new
2490 FamilySelector familySelector = FamilySelector();
2493 case OMF_None: llvm_unreachable(
"logic error, no method convention");
2507 case OMF_init: familySelector = F_init;
break;
2508 case OMF_alloc: familySelector = F_alloc;
break;
2509 case OMF_copy: familySelector = F_copy;
break;
2511 case OMF_new: familySelector = F_new;
break;
2514 enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn };
2515 ReasonSelector reasonSelector;
2520 reasonSelector = R_UnrelatedReturn;
2522 reasonSelector = R_NonObjectReturn;
2525 S.
Diag(impl->
getLocation(), errorID) <<
int(familySelector) << int(reasonSelector);
2526 S.
Diag(decl->
getLocation(), noteID) <<
int(familySelector) << int(reasonSelector);
2533 bool IsProtocolMethodDecl) {
2539 IsProtocolMethodDecl,
false,
2545 IM != EM && IF != EF; ++IM, ++IF) {
2547 IsProtocolMethodDecl,
false,
true);
2552 diag::warn_conflicting_variadic);
2559 bool IsProtocolMethodDecl) {
2562 IsProtocolMethodDecl,
true,
2568 IM != EM && IF != EF; ++IM, ++IF) {
2570 IsProtocolMethodDecl,
true,
true);
2575 diag::warn_conflicting_overriding_variadic);
2584 bool IsProtocolMethodDecl) {
2592 if (MethodDecl->
hasAttr<UnavailableAttr>() ||
2593 MethodDecl->
hasAttr<DeprecatedAttr>())
2597 IsProtocolMethodDecl,
false,
false);
2602 IM != EM && IF != EF; ++IM, ++IF) {
2605 IsProtocolMethodDecl,
false,
false);
2617 diag::warn_category_method_impl_match);
2634 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>())
2636 for (
const auto *PI : PDecl->
protocols())
2659 bool& IncompleteImpl,
2667 assert (IDecl &&
"CheckProtocolMethodDefs - IDecl is null");
2683 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>()) {
2684 if (!ProtocolsExplictImpl) {
2689 ProtocolsExplictImpl->end())
2707 if (InsMap.count(fISelector))
2727 !method->isPropertyAccessor() &&
2728 !InsMap.count(method->getSelector()) &&
2744 IDecl->lookupMethod(method->getSelector(),
2748 if (C || MethodInClass->isPropertyAccessor())
2750 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2760 !ClsMap.count(method->getSelector()) &&
2767 if (C && IDecl->lookupMethod(method->getSelector(),
2773 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2782 CDecl, ProtocolsExplictImpl);
2794 bool &IncompleteImpl,
2795 bool ImmediateClass,
2796 bool WarnCategoryMethodImpl) {
2800 if (!InsMapSeen.insert(I->getSelector()).second)
2802 if (!I->isPropertyAccessor() &&
2803 !InsMap.count(I->getSelector())) {
2806 diag::warn_undef_method_impl);
2812 "Expected to find the method through lookup as well");
2814 if (ImpMethodDecl) {
2815 if (!WarnCategoryMethodImpl)
2817 isa<ObjCProtocolDecl>(CDecl));
2818 else if (!I->isPropertyAccessor())
2827 if (!ClsMapSeen.insert(I->getSelector()).second)
2829 if (!I->isPropertyAccessor() &&
2830 !ClsMap.count(I->getSelector())) {
2833 diag::warn_undef_method_impl);
2838 "Expected to find the method through lookup as well");
2840 if (ImpMethodDecl) {
2841 if (!WarnCategoryMethodImpl)
2843 isa<ObjCProtocolDecl>(CDecl));
2844 else if (!I->isPropertyAccessor())
2853 for (
auto *PI : PD->protocols())
2855 IMPDecl, PI, IncompleteImpl,
false,
2856 WarnCategoryMethodImpl);
2863 if (!WarnCategoryMethodImpl) {
2864 for (
auto *Cat : I->visible_categories())
2866 IMPDecl, Cat, IncompleteImpl,
2867 ImmediateClass && Cat->IsClassExtension(),
2868 WarnCategoryMethodImpl);
2871 for (
auto *Ext : I->visible_extensions())
2873 IMPDecl, Ext, IncompleteImpl,
false,
2874 WarnCategoryMethodImpl);
2878 for (
auto *PI : I->all_referenced_protocols())
2880 IMPDecl, PI, IncompleteImpl,
false,
2881 WarnCategoryMethodImpl);
2885 if (!WarnCategoryMethodImpl && I->getSuperClass())
2888 I->getSuperClass(), IncompleteImpl,
false);
2919 if (SuperIDecl && SuperIDecl->
lookupMethod(Sel,
false))
2923 if (InsMap.empty() && ClsMap.empty())
2927 bool IncompleteImpl =
false;
2930 IncompleteImpl,
false,
2936 bool IncompleteImpl) {
2941 InsMap.insert(I->getSelector());
2949 const auto *
P = PImpl->getPropertyDecl();
2952 InsMap.insert(
P->getGetterName());
2953 if (!
P->getSetterName().isNull())
2954 InsMap.insert(
P->getSetterName());
2961 bool SynthesizeProperties =
LangOpts.ObjCDefaultSynthProperties &&
2963 !IDecl->isObjCRequiresPropertyDefs();
2972 ClsMap.insert(I->getSelector());
2979 IncompleteImpl,
true);
2984 dyn_cast<ObjCCategoryImplDecl>(IMPDecl))
2995 for (
auto *PI : I->all_referenced_protocols())
2997 InsMap, ClsMap, I, ExplicitImplProtocols);
3001 if (!
C->IsClassExtension()) {
3002 for (
auto *
P :
C->protocols())
3004 IncompleteImpl, InsMap, ClsMap, CDecl,
3005 ExplicitImplProtocols);
3010 llvm_unreachable(
"invalid ObjCContainerDecl type.");
3020 for (
unsigned i = 0; i != NumElts; ++i) {
3025 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
3035 Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
3043 Diag(AtClassLoc, diag::warn_forward_class_redefinition)
3053 = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
3075 if (PrevIDecl && TypeParams) {
3079 *
this, PrevTypeParams, TypeParams,
3080 TypeParamListContext::ForwardDeclaration)) {
3081 TypeParams =
nullptr;
3085 Diag(IdentLocs[i], diag::err_objc_parameterized_forward_class)
3088 Diag(Def->getLocation(), diag::note_defined_here)
3091 TypeParams =
nullptr;
3097 ClassName, TypeParams, PrevIDecl,
3103 DeclsInGroup.push_back(IDecl);
3111 const Type *left,
const Type *right);
3120 if (left == right)
return true;
3143 if (isa<VectorType>(left))
return isa<VectorType>(right);
3144 if (isa<VectorType>(right))
return false;
3167 return (leftSK == rightSK);
3173 assert(lt && rt && lt != rt);
3175 if (!isa<RecordType>(lt) || !isa<RecordType>(rt))
return false;
3176 RecordDecl *left = cast<RecordType>(lt)->getDecl();
3177 RecordDecl *right = cast<RecordType>(rt)->getDecl();
3183 if ((isa<CXXRecordDecl>(left) && !cast<CXXRecordDecl>(left)->isPOD()) ||
3184 (isa<CXXRecordDecl>(right) && !cast<CXXRecordDecl>(right)->isPOD()))
3199 for (; li != le && ri != re; ++li, ++ri) {
3200 if (!
matchTypes(Context, strategy, li->getType(), ri->getType()))
3203 return (li == le && ri == re);
3221 (left->
hasAttr<NSReturnsRetainedAttr>()
3222 != right->
hasAttr<NSReturnsRetainedAttr>() ||
3223 left->
hasAttr<NSConsumesSelfAttr>()
3224 != right->
hasAttr<NSConsumesSelfAttr>()))
3231 for (; li != le && ri != re; ++li, ++ri) {
3232 assert(ri != right->
param_end() &&
"Param mismatch");
3235 if (!
matchTypes(Context, strategy, lparm->getType(), rparm->getType()))
3239 lparm->hasAttr<NSConsumedAttr>() != rparm->hasAttr<NSConsumedAttr>())
3248 auto *MethodInListProtocol =
3252 if ((MethodProtocol && !MethodInListProtocol) ||
3253 (!MethodProtocol && MethodInListProtocol))
3256 if (MethodProtocol && MethodInListProtocol)
3262 return MethodInterface == MethodInListInterface;
3271 if (!CD->IsClassExtension() && List->
getBits() < 2)
3285 for (; List; Previous = List, List = List->
getNext()) {
3302 if (!SameDeclaration ||
3308 List->setHasMoreThanOneDecl(
true);
3314 ListWithSameDeclaration = List;
3317 !ListWithSameDeclaration &&
3319 ListWithSameDeclaration = List;
3333 List->setHasMoreThanOneDecl(
true);
3340 List->setMethod(Method);
3346 List->setMethod(Method);
3357 if (ListWithSameDeclaration) {
3360 ListWithSameDeclaration->
setMethod(Method);
3361 ListWithSameDeclaration->
setNext(List);
3371 assert(ExternalSource &&
"We need an external AST source");
3372 ExternalSource->ReadMethodPool(Sel);
3376 if (!ExternalSource)
3378 ExternalSource->updateOutOfDateSelector(Sel);
3381 void Sema::AddMethodToGlobalPool(
ObjCMethodDecl *Method,
bool impl,
3397 ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
3431 assert(BoundInterface &&
"unexpected object type!");
3436 if (MethodProtocol) {
3446 return MethodInterface == BoundInterface ||
3447 MethodInterface->isSuperClassOf(BoundInterface) ||
3448 BoundInterface->isSuperClassOf(MethodInterface);
3450 llvm_unreachable(
"unknown method context");
3457 bool InstanceFirst,
bool CheckTheOther,
3462 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3470 if (M->getMethod() && !M->getMethod()->isHidden()) {
3472 Methods.push_back(M->getMethod());
3476 if (!Methods.empty())
3477 return Methods.size() > 1;
3486 if (M->getMethod() && !M->getMethod()->isHidden()) {
3488 Methods.push_back(M->getMethod());
3491 return Methods.size() > 1;
3499 FilteredMethods.push_back(BestMethod);
3501 for (
auto *M : Methods)
3502 if (M != BestMethod && !M->
hasAttr<UnavailableAttr>())
3503 FilteredMethods.push_back(M);
3505 if (FilteredMethods.size() > 1)
3509 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3520 bool receiverIdOrClass,
3525 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3530 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
3533 if (M->getMethod() && !M->getMethod()->isHidden())
3534 return M->getMethod();
3541 bool receiverIdOrClass) {
3543 bool issueDiagnostic =
false, issueError =
false;
3547 bool strictSelectorMatch =
3548 receiverIdOrClass &&
3550 if (strictSelectorMatch) {
3551 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3553 issueDiagnostic =
true;
3562 if (!strictSelectorMatch ||
3563 (issueDiagnostic &&
getLangOpts().ObjCAutoRefCount))
3564 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3568 issueDiagnostic =
true;
3575 if (issueDiagnostic) {
3577 Diag(R.
getBegin(), diag::err_arc_multiple_method_decl) << Sel << R;
3578 else if (strictSelectorMatch)
3579 Diag(R.
getBegin(), diag::warn_strict_multiple_method_decl) << Sel << R;
3581 Diag(R.
getBegin(), diag::warn_multiple_method_decl) << Sel << R;
3583 Diag(Methods[0]->getLocStart(),
3584 issueError ? diag::note_possibility : diag::note_using)
3585 << Methods[0]->getSourceRange();
3586 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3587 Diag(Methods[I]->getLocStart(), diag::note_also_found)
3588 << Methods[I]->getSourceRange();
3594 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3600 Method = Method->getNext())
3601 if (Method->getMethod() &&
3604 return Method->getMethod();
3607 Method = Method->getNext())
3608 if (Method->getMethod() &&
3611 return Method->getMethod();
3619 const unsigned MaxEditDistance = 1;
3620 unsigned BestEditDistance = MaxEditDistance + 1;
3623 unsigned MinPossibleEditDistance =
abs((
int)MethodName.size() - (int)Typo.size());
3624 if (MinPossibleEditDistance > 0 &&
3625 Typo.size() / MinPossibleEditDistance < 1)
3627 unsigned EditDistance = Typo.edit_distance(MethodName,
true, MaxEditDistance);
3628 if (EditDistance > MaxEditDistance)
3630 if (EditDistance == BestEditDistance)
3631 BestMethod.push_back(Method);
3632 else if (EditDistance < BestEditDistance) {
3634 BestMethod.push_back(Method);
3653 bool ObjectIsId =
true, ObjectIsClass =
true;
3655 ObjectIsId = ObjectIsClass =
false;
3660 ObjectType =
QualType(ObjCPtr->getInterfaceType(), 0);
3661 ObjectIsId = ObjectIsClass =
false;
3664 ObjectIsClass =
false;
3670 for (GlobalMethodPool::iterator b =
MethodPool.begin(),
3674 if (M->getMethod() &&
3675 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3676 (M->getMethod()->getSelector() != Sel)) {
3678 Methods.push_back(M->getMethod());
3679 else if (!ObjectIsClass &&
3682 Methods.push_back(M->getMethod());
3686 if (M->getMethod() &&
3687 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3688 (M->getMethod()->getSelector() != Sel)) {
3690 Methods.push_back(M->getMethod());
3691 else if (!ObjectIsId &&
3694 Methods.push_back(M->getMethod());
3699 for (
unsigned i = 0, e = Methods.size(); i < e; i++) {
3703 return (SelectedMethods.size() == 1) ? SelectedMethods[0] :
nullptr;
3713 for (
auto *Ivar : ID->
ivars()) {
3714 if (Ivar->isInvalidDecl())
3719 Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
3721 Ivar->setInvalidDecl();
3733 if (ivar->isInvalidDecl())
continue;
3736 S.
Diag(ivar->getLocation(), diag::err_arc_weak_disabled);
3738 S.
Diag(ivar->getLocation(), diag::err_arc_weak_no_runtime);
3752 if (ivar->isInvalidDecl())
3758 S.
Diag(ivar->getLocation(), diag::err_flexible_array_arc_retainable);
3759 ivar->setInvalidDecl();
3766 case Decl::ObjCInterface:
3768 case Decl::ObjCProtocol:
3770 case Decl::ObjCCategory:
3771 if (cast<ObjCCategoryDecl>(
CurContext)->IsClassExtension())
3774 case Decl::ObjCImplementation:
3776 case Decl::ObjCCategoryImpl:
3788 return (RecordTy && RecordTy->getDecl()->hasFlexibleArrayMember());
3795 if ((IntfDecl = dyn_cast<ObjCInterfaceDecl>(OCD))) {
3796 Ivars = IntfDecl->
ivars();
3797 }
else if (
auto *ImplDecl = dyn_cast<ObjCImplementationDecl>(OCD)) {
3798 IntfDecl = ImplDecl->getClassInterface();
3799 Ivars = ImplDecl->
ivars();
3800 }
else if (
auto *CategoryDecl = dyn_cast<ObjCCategoryDecl>(OCD)) {
3801 if (CategoryDecl->IsClassExtension()) {
3802 IntfDecl = CategoryDecl->getClassInterface();
3803 Ivars = CategoryDecl->
ivars();
3808 if (!isa<ObjCInterfaceDecl>(OCD)) {
3809 for (
auto ivar : Ivars) {
3811 S.
Diag(ivar->getLocation(), diag::warn_variable_sized_ivar_visibility)
3812 << ivar->getDeclName() << ivar->getType();
3824 if (ivar->isInvalidDecl() || !ivar->getNextIvar())
3827 bool IsInvalidIvar =
false;
3829 S.
Diag(ivar->getLocation(), diag::err_flexible_array_not_at_end)
3830 << ivar->getDeclName() << IvarTy
3832 IsInvalidIvar =
true;
3834 if (RecordTy->getDecl()->hasFlexibleArrayMember()) {
3835 S.
Diag(ivar->getLocation(),
3836 diag::err_objc_variable_sized_type_not_at_end)
3837 << ivar->getDeclName() << IvarTy;
3838 IsInvalidIvar =
true;
3841 if (IsInvalidIvar) {
3842 S.
Diag(ivar->getNextIvar()->getLocation(),
3843 diag::note_next_ivar_declaration)
3844 << ivar->getNextIvar()->getSynthesize();
3845 ivar->setInvalidDecl();
3853 (Ivars.begin() == Ivars.end()) ?
nullptr : *Ivars.begin();
3856 while (SuperClass && SuperClass->
ivar_empty())
3860 std::advance(IvarIter, SuperClass->
ivar_size() - 1);
3864 diag::warn_superclass_variable_sized_type_not_at_end)
3865 << FirstIvar->
getDeclName() << LastIvar->getDeclName()
3866 << LastIvar->getType() << SuperClass->
getDeclName();
3867 S.
Diag(LastIvar->getLocation(), diag::note_entity_declared_at)
3868 << LastIvar->getDeclName();
3880 assert(AtEnd.
isValid() &&
"Invalid location for '@end'");
3882 auto *OCD = cast<ObjCContainerDecl>(
CurContext);
3883 Decl *ClassDecl = OCD;
3885 bool isInterfaceDeclKind =
3886 isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl)
3887 || isa<ObjCProtocolDecl>(ClassDecl);
3888 bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
3891 llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap;
3892 llvm::DenseMap<Selector, const ObjCMethodDecl*> ClsMap;
3894 for (
unsigned i = 0, e = allMethods.size(); i != e; i++ ) {
3896 cast_or_null<ObjCMethodDecl>(allMethods[i]);
3898 if (!Method)
continue;
3904 if ((isInterfaceDeclKind && PrevMethod && !match)
3905 || (checkIdenticalMethods && match)) {
3928 if ((isInterfaceDeclKind && PrevMethod && !match)
3929 || (checkIdenticalMethods && match)) {
3948 if (isa<ObjCInterfaceDecl>(ClassDecl)) {
3955 if (
C->IsClassExtension()) {
3961 if (CDecl->getIdentifier())
3965 for (
auto *I : CDecl->properties())
3967 CDecl->setAtEndRange(AtEnd);
3970 IC->setAtEndRange(AtEnd);
3977 for (
const auto *Ext : IDecl->visible_extensions()) {
3978 for (
const auto *
Property : Ext->instance_properties()) {
3981 = IC->FindPropertyImplDecl(
Property->getIdentifier(),
3983 if (PIDecl->getPropertyImplementation()
3987 for (
const auto *Ext : IDecl->visible_extensions()) {
3989 = Ext->getInstanceMethod(
Property->getGetterName()))
3990 GetterMethod->setPropertyAccessor(
true);
3993 = Ext->getInstanceMethod(
Property->getSetterName()))
3994 SetterMethod->setPropertyAccessor(
true);
4002 if (IDecl->hasDesignatedInitializers())
4007 bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>();
4008 if (IDecl->getSuperClass() ==
nullptr) {
4011 if (!HasRootClassAttr) {
4014 Diag(DeclLoc, diag::warn_objc_root_class_missing)
4015 << IDecl->getIdentifier();
4022 if (NSObjectDecl && NSObjectDecl->getDefinition()) {
4023 Diag(SuperClassLoc, diag::note_objc_needs_superclass)
4026 Diag(SuperClassLoc, diag::note_objc_needs_superclass);
4029 }
else if (HasRootClassAttr) {
4031 Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass);
4039 if (IDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4040 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4041 Diag(IC->getLocation(), diag::err_restricted_superclass_mismatch);
4042 Diag(Super->getLocation(), diag::note_class_declared);
4047 while (IDecl->getSuperClass()) {
4049 IDecl = IDecl->getSuperClass();
4055 dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
4056 CatImplClass->setAtEndRange(AtEnd);
4062 = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier())) {
4066 }
else if (
const auto *IntfDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
4068 if (!IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4069 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4070 Diag(IntfDecl->getLocation(), diag::err_restricted_superclass_mismatch);
4071 Diag(Super->getLocation(), diag::note_class_declared);
4076 if (isInterfaceDeclKind) {
4078 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4081 if (
VarDecl *VDecl = dyn_cast<VarDecl>(*I)) {
4082 if (!VDecl->hasExternalStorage())
4083 Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass);
4089 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4092 (*I)->setTopLevelDeclInObjCContainer();
4121 if (ResultObjectType->isObjCIdType() ||
4122 ResultObjectType->isObjCQualifiedIdType())
4127 = ResultObjectType->getInterfaceDecl()) {
4133 if (ResultClass->isSuperClassOf(CurrentClass))
4149 class OverrideSearch {
4162 Sema::GlobalMethodPool::iterator it = S.
MethodPool.find(selector);
4182 searchFromContainer(container);
4184 searchFromContainer(Interface);
4186 searchFromContainer(container);
4190 typedef decltype(Overridden)::iterator iterator;
4191 iterator begin()
const {
return Overridden.begin(); }
4192 iterator end()
const {
return Overridden.end(); }
4199 #define OBJCCONTAINER(type, base) \ 4201 searchFrom(cast<type##Decl>(container)); \ 4203 #define ABSTRACT_DECL(expansion) 4204 #define DECL(type, base) \ 4206 #include "clang/AST/DeclNodes.inc" 4207 llvm_unreachable(
"not an ObjC container!");
4280 Overridden.insert(meth);
4290 searchFromContainer(container);
4299 OverrideSearch overrides(*
this, ObjCMethod);
4305 bool hasOverriddenMethodsInBaseOrProtocol =
false;
4306 for (OverrideSearch::iterator
4307 i = overrides.begin(), e = overrides.end(); i != e; ++i) {
4310 if (!hasOverriddenMethodsInBaseOrProtocol) {
4314 hasOverriddenMethodsInBaseOrProtocol =
true;
4324 GlobalMethodPool::iterator It =
4329 unsigned CategCount = List.
getBits();
4330 if (CategCount > 0) {
4333 if (CategCount > 1 ||
4335 OverrideSearch overrides(*
this, overridden);
4336 for (OverrideSearch::iterator
4337 OI= overrides.begin(), OE= overrides.end(); OI!=OE; ++OI) {
4341 hasOverriddenMethodsInBaseOrProtocol =
true;
4368 if (CurrentClass && overridden->
getDeclContext() != CurrentClass &&
4375 for (; ParamI != E && PrevI != PrevE; ++ParamI, ++PrevI) {
4376 assert(PrevI != overridden->
param_end() &&
"Param mismatch");
4382 Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
4391 ObjCMethod->
setOverriding(hasOverriddenMethodsInBaseOrProtocol);
4401 bool prevUsesCSKeyword) {
4407 if (nullability.hasValue() == prevNullability.hasValue()) {
4413 if (*nullability == *prevNullability)
4417 S.
Diag(loc, diag::err_nullability_conflicting)
4440 if (prevMethod->
hasAttr<ObjCRequiresSuperAttr>() &&
4441 !method->
hasAttr<ObjCRequiresSuperAttr>()) {
4444 ObjCRequiresSuperAttr::CreateImplicit(S.
Context,
4461 unsigned numPrevParams = prevMethod->
param_size();
4462 for (
unsigned i = 0, n =
std::min(numParams, numPrevParams); i != n; ++i) {
4482 llvm::Triple::x86 &&
4483 "x86-specific check invoked for a different target");
4487 if (
P->getType()->isVectorType()) {
4488 Loc =
P->getLocStart();
4493 if (Loc.isInvalid()) {
4504 VersionTuple AcceptedInVersion;
4505 if (Triple.getOS() == llvm::Triple::IOS)
4506 AcceptedInVersion = VersionTuple(9);
4507 else if (Triple.isMacOSX())
4508 AcceptedInVersion = VersionTuple(10, 11);
4514 SemaRef.
Diag(Loc, diag::err_objc_method_unsupported_param_ret_type)
4517 << (Triple.isMacOSX() ?
"macOS 10.11" :
"iOS 9");
4529 bool isVariadic,
bool MethodDefinition) {
4532 Diag(MethodLoc, diag::err_missing_method_context);
4538 bool HasRelatedResultType =
false;
4546 QualType bareResultType = resultDeclType;
4551 Diag(MethodLoc, diag::warn_missing_method_return_type)
4556 Context, MethodLoc, EndLoc, Sel, resultDeclType, ReturnTInfo,
CurContext,
4557 MethodType == tok::minus, isVariadic,
4562 HasRelatedResultType);
4566 for (
unsigned i = 0, e = Sel.
getNumArgs(); i != e; ++i) {
4570 if (!ArgInfo[i].
Type) {
4577 LookupResult R(*
this, ArgInfo[i].Name, ArgInfo[i].NameLoc,
4583 Diag(ArgInfo[i].NameLoc,
4584 (MethodDefinition ? diag::warn_method_param_redefinition
4585 : diag::warn_method_param_declaration))
4588 diag::note_previous_declaration);
4597 ArgInfo[i].NameLoc, ArgInfo[i].Name,
4609 if (Param->
hasAttr<BlocksAttr>()) {
4616 Params.push_back(Param);
4619 for (
unsigned i = 0, e = CNumArgs; i != e; ++i) {
4622 if (ArgType.isNull())
4629 Params.push_back(Param);
4632 ObjCMethod->setMethodParams(Context, Params, SelectorLocs);
4633 ObjCMethod->setObjCDeclQualifier(
4641 if (
ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(ClassDecl)) {
4642 if (MethodType == tok::minus) {
4643 PrevMethod = ImpDecl->getInstanceMethod(Sel);
4644 ImpDecl->addInstanceMethod(ObjCMethod);
4646 PrevMethod = ImpDecl->getClassMethod(Sel);
4647 ImpDecl->addClassMethod(ObjCMethod);
4653 if (
auto *IMD = IDecl->lookupMethod(ObjCMethod->getSelector(),
4654 ObjCMethod->isInstanceMethod())) {
4658 if (isa<ObjCCategoryImplDecl>(ImpDecl) && IMD->isOverriding() &&
4659 ObjCMethod->getSelector().getMethodFamily() ==
OMF_dealloc) {
4660 Diag(ObjCMethod->getLocation(), diag::warn_dealloc_in_category)
4661 << ObjCMethod->getDeclName();
4668 for (
auto *
C : IDecl->visible_categories())
4669 for (
auto &
P :
C->protocols())
4670 if (
auto *IMD =
P->lookupMethod(ObjCMethod->getSelector(),
4671 ObjCMethod->isInstanceMethod())) {
4672 assert(ObjCMethod->parameters().size() ==
4673 IMD->parameters().size() &&
4674 "Methods have different number of parameters");
4675 auto OI = IMD->param_begin(), OE = IMD->param_end();
4676 auto NI = ObjCMethod->param_begin();
4677 for (; OI != OE; ++OI, ++NI)
4682 cast<DeclContext>(ClassDecl)->addDecl(ObjCMethod);
4687 Diag(ObjCMethod->getLocation(), diag::err_duplicate_method_decl)
4688 << ObjCMethod->getDeclName();
4690 ObjCMethod->setInvalidDecl();
4698 if (!CurrentClass) {
4700 CurrentClass = Cat->getClassInterface();
4701 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(ClassDecl))
4702 CurrentClass = Impl->getClassInterface();
4704 = dyn_cast<ObjCCategoryImplDecl>(ClassDecl))
4705 CurrentClass = CatImpl->getClassInterface();
4713 bool ARCError =
false;
4719 !ObjCMethod->hasRelatedResultType() &&
4720 LangOpts.ObjCInferRelatedResultType) {
4721 bool InferRelatedResultType =
false;
4722 switch (ObjCMethod->getMethodFamily()) {
4736 InferRelatedResultType = ObjCMethod->isClassMethod();
4743 InferRelatedResultType = ObjCMethod->isInstanceMethod();
4747 if (InferRelatedResultType &&
4748 !ObjCMethod->getReturnType()->isObjCIndependentClassType())
4749 ObjCMethod->SetRelatedResultType();
4752 if (MethodDefinition &&
4758 if (
const auto *attr = ObjCMethod->getAttr<AvailabilityAttr>()) {
4759 if (ObjCMethod->isClassMethod() &&
4760 ObjCMethod->getSelector().getAsString() ==
"load") {
4761 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer)
4763 ObjCMethod->dropAttr<AvailabilityAttr>();
4783 Diag(D->
getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
4797 Diag(DeclStart, diag::err_undef_interface) << ClassName;
4801 Diag(DeclStart, diag::err_atdef_nonfragile_interface);
4809 for (
unsigned i = 0; i < Ivars.size(); i++) {
4817 Decls.push_back(FD);
4822 D != Decls.end(); ++D) {
4826 else if (
RecordDecl *Record = dyn_cast<RecordDecl>(TagD))
4827 Record->addDecl(FD);
4842 Diag(IdLoc, diag::err_arg_with_address_space);
4854 Diag(IdLoc, diag::err_illegal_qualifiers_on_catch_parm);
4859 Diag(IdLoc, diag::err_catch_param_not_objc_type);
4862 Diag(IdLoc, diag::err_catch_param_not_objc_type);
4895 diag::err_invalid_thread)
4929 if (New->
hasAttr<BlocksAttr>())
4942 Ivars.push_back(Iv);
4948 if (ExternalSource) {
4950 ExternalSource->ReadReferencedSelectors(Sels);
4951 for (
unsigned I = 0, N = Sels.size(); I != N; ++I)
4962 Selector Sel = SelectorAndLocation.first;
4965 Diag(Loc, diag::warn_unimplemented_selector) << Sel;
4988 IV->getIdentifier());
4997 class UnusedBackingIvarChecker :
5004 bool InvokedSelfMethod;
5008 : S(S), Method(Method), IvarD(IvarD),
5009 AccessedIvar(
false), InvokedSelfMethod(
false) {
5015 AccessedIvar =
true;
5024 InvokedSelfMethod =
true;
5037 unsigned DIAG = diag::warn_unused_property_backing_ivar;
5047 UnusedBackingIvarChecker Checker(*
this, CurMethod, IV);
5048 Checker.TraverseStmt(CurMethod->getBody());
5049 if (Checker.AccessedIvar)
5056 if (!IV->
isReferenced() || !Checker.InvokedSelfMethod) {
5057 Diag(Loc, DIAG) << IV;
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl *> allMethods=None, ArrayRef< DeclGroupPtrTy > allTUVars=None)
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
bool hasDefinition() const
Determine whether this class has been defined.
static bool tryMatchRecordTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, const Type *left, const Type *right)
ObjCIvarDecl * GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, const ObjCPropertyDecl *&PDecl) const
GetIvarBackingPropertyAccessor - If method is a property setter/getter and it property has a backing ...
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, ObjCInterfaceDecl *ID)
DiagnoseClassExtensionDupMethods - Check for duplicate declaration of a class method in its extension...
bool isClassMethod() const
Decl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
void setImplicit(bool I=true)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
The receiver is an object instance.
void setEndOfDefinitionLoc(SourceLocation LE)
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled...
ExternalSemaSource * getExternalSource() const
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
void setStarLoc(SourceLocation Loc)
unsigned param_size() const
ObjCInterfaceDecl * getClassInterface()
all_protocol_range all_referenced_protocols() const
ObjCInterfaceDecl * getClassInterface()
void 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.
static ClassTemplateDecl * getDefinition(ClassTemplateDecl *D)
llvm::DenseSet< IdentifierInfo * > ProtocolNameSet
FIXME: Type hierarchies in Objective-C can be deep.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
Look up the name of an Objective-C protocol.
const ObjCProtocolList & getReferencedProtocols() const
Expr * getBitWidth() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
static bool CheckMethodOverrideParam(Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, ParmVarDecl *ImplVar, ParmVarDecl *IfaceVar, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn)
Defines the SourceManager interface.
void ActOnDocumentableDecl(Decl *D)
Should be called on all declarations that might have attached documentation comments.
bool isRecordType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
__DEVICE__ long long abs(long long __n)
Captures information about "declaration specifiers" specific to Objective-C.
ObjCTypeParamList * actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef< Decl *> typeParams, SourceLocation rAngleLoc)
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl, ObjCProtocolDecl *&UndefinedProtocol)
known_categories_range known_categories() const
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
bool CheckForwardProtocolDeclarationForCircularDependency(IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, const ObjCList< ObjCProtocolDecl > &PList)
The base class of the type hierarchy.
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
The parameter is covariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant and ...
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
bool isCompilingModule() const
Are we compiling a module interface (.cppm or module map)?
bool isObjCContainer() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
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. ...
Represents a variable declaration or definition.
void setImplementation(ObjCCategoryImplDecl *ImplD)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Information about one declarator, including the parsed type information and the identifier.
DiagnosticsEngine & Diags
const T * getAs() const
Member-template getAs<specific type>'.
ObjCCategoryImplDecl * getImplementation() const
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
Represents a parameter to a function.
The collection of all-type qualifiers we support.
const ObjCInterfaceDecl * getSuperClass() const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
Represents a struct/union/class.
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
static void checkObjCMethodX86VectorTypes(Sema &SemaRef, const ObjCMethodDecl *Method)
Verify that the method parameters/return value have types that are supported by the x86 target...
const ObjCProtocolList & getReferencedProtocols() const
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
const ParmVarDecl *const * param_const_iterator
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
ObjCMethodFamily
A family of Objective-C methods.
The parameter is contravariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant ...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
void set(T *const *InList, unsigned Elts, ASTContext &Ctx)
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
bool isObjCIdType() const
Represents a member of a struct/union/class.
SourceRange getReturnTypeSourceRange() const
instmeth_range instance_methods() const
void setSuperClass(TypeSourceInfo *superClass)
method_range methods() const
SourceRange getSourceRange() const
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList *> TypeParamLists, unsigned NumElts)
void ClearStorageClassSpecs()
void setReturnType(QualType T)
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc, SourceLocation UnalignedQualLoc)
Return a DeclaratorChunk for a pointer.
static bool checkTypeParamListConsistency(Sema &S, ObjCTypeParamList *prevTypeParams, ObjCTypeParamList *newTypeParams, TypeParamListContext newContext)
Check consistency between two Objective-C type parameter lists, e.g., between a category/extension an...
bool isObjCQualifiedClassType() const
static bool FilterMethodsByTypeBound(ObjCMethodDecl *Method, const ObjCObjectType *TypeBound)
Return true if the given method is wthin the type bound.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
llvm::BumpPtrAllocator BumpAlloc
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
bool isInvalidType() const
bool isUnarySelector() const
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void MatchAllMethodDeclarations(const SelectorSet &InsMap, const SelectorSet &ClsMap, SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool &IncompleteImpl, bool ImmediateClass, bool WarnCategoryMethodImpl=false)
MatchAllMethodDeclarations - Check methods declaraed in interface or or protocol against those declar...
bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall)
Check whether the given method, which must be in the 'init' family, is a valid member of that family...
void setMethod(ObjCMethodDecl *M)
bool isBitField() const
Determines whether this field is a bitfield.
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
Represents the results of name lookup.
ObjCMethodDecl * LookupImplementedMethodInGlobalPool(Selector Sel)
LookupImplementedMethodInGlobalPool - Returns the method which has an implementation.
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool isReferenced() const
Whether any declaration of this entity was referenced.
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
SCS
storage-class-specifier
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl *> &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl *> Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Decl * ActOnObjCContainerStartDefinition(Decl *IDecl)
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, IdentifierInfo *ClassName, SmallVectorImpl< Decl *> &Decls)
Called whenever @defs(ClassName) is encountered in the source.
const clang::PrintingPolicy & getPrintingPolicy() const
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Represents a declaration of a type.
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
void setExceptionVariable(bool EV)
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, ArrayRef< IdentifierLocPair > ProtocolId, SmallVectorImpl< Decl *> &Protocols)
FindProtocolDeclaration - This routine looks up protocols and issues an error if they are not declare...
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Scope - A scope is a transient data structure that is used while parsing the program.
const ObjCMethodDecl * SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType())
static bool CheckMethodOverrideReturn(Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn)
field_iterator field_begin() const
unsigned getBitWidthValue(const ASTContext &Ctx) const
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
Represents an Objective-C protocol declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool isScalarType() const
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
Decl * ActOnObjCExceptionDecl(Scope *S, Declarator &D)
#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
This object can be modified without requiring retains or releases.
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
AvailabilityResult
Captures the result of checking the availability of a declaration.
static Decl::ObjCDeclQualifier CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal)
CvtQTToAstBitMask - utility routine to produce an AST bitmask for objective-c's type qualifier from t...
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl *> Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
static bool isAcceptableMethodMismatch(ObjCMethodDecl *chosen, ObjCMethodDecl *other)
Determines if this is an "acceptable" loose mismatch in the global method pool.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Sema - This implements semantic analysis and AST building for C.
visible_extensions_range visible_extensions() const
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
SourceLocation getLocStart() const LLVM_READONLY
ResultTypeCompatibilityKind
Describes the compatibility of a result type with its method.
llvm::SmallPtrSet< Selector, 8 > SelectorSet
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
bool inferObjCARCLifetime(ValueDecl *decl)
void SetRangeStart(SourceLocation Loc)
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, const ParsedAttributesView &attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
SourceRange getRange() const
void ActOnSuperClassOfClassInterface(Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange)
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl *> Decls)
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
bool AnyObjCImplementation()
Return true if there is at least one @implementation in the TU.
unsigned ivar_size() const
TypeSourceInfo * getTypeSourceInfo() const
bool hasDefinition() const
Determine whether this protocol has a definition.
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl *> &Ivars) const
DeepCollectObjCIvars - This routine first collects all declared, but not synthesized, ivars in super class and then collects all ivars, including those synthesized for current class.
SourceLocation getBeginLoc() const
Get the begin source location.
Type source information for an attributed type.
LookupNameKind
Describes the kind of name lookup to perform.
ObjCMethodList * getNext() const
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
ivar_iterator ivar_begin() const
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
TypeResult ActOnTypeName(Scope *S, Declarator &D)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type...
static void DiagnoseObjCImplementedDeprecations(Sema &S, const NamedDecl *ND, SourceLocation ImplLoc)
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
SourceLocation getThreadStorageClassSpecLoc() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setAtEndRange(SourceRange atEnd)
void ActOnStartOfObjCMethodDef(Scope *S, Decl *D)
ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible and user declared, in the method definition's AST.
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)
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
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void setTopLevelDeclInObjCContainer(bool V=true)
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl *> Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
ivar_iterator ivar_end() const
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
LangAS getAddressSpace() const
Return the address space of this type.
ObjCProtocolDecl *const * iterator
Interfaces are the core concept in Objective-C for object oriented design.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
static bool diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, Sema &S)
Issue a warning if the parameter of the overridden method is non-escaping but the parameter of the ov...
static void mergeInterfaceMethodToImpl(Sema &S, ObjCMethodDecl *method, ObjCMethodDecl *prevMethod)
Merge information from the declaration of a method in the @interface (or a category/extension) into t...
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
SourceLocation getLocStart() const LLVM_READONLY
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AL, bool IncludeCXX11Attributes=true)
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
static bool objcModifiersConflict(Decl::ObjCDeclQualifier x, Decl::ObjCDeclQualifier y)
Determine whether two set of Objective-C declaration qualifiers conflict.
ObjCCategoryDecl * getCategoryDecl() const
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method, and set any properties that should be inherited.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static QualType mergeTypeNullabilityForRedecl(Sema &S, SourceLocation loc, QualType type, bool usesCSKeyword, SourceLocation prevLoc, QualType prevType, bool prevUsesCSKeyword)
Merge type nullability from for a redeclaration of the same entity, producing the updated type of the...
std::unique_ptr< ProtocolNameSet > LazyProtocolNameSet
void DiagnoseUseOfUnimplementedSelectors()
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
static bool isObjCTypeSubstitutable(ASTContext &Context, const ObjCObjectPointerType *A, const ObjCObjectPointerType *B, bool rejectId)
Determines if type B can be substituted for type A.
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
ObjCCategoryDecl - Represents a category declaration.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Look up any declaration with any name.
Decl * ActOnStartClassInterface(Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
bool isObjCObjectPointerType() const
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
Represents one property declaration in an Objective-C interface.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
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)
We first select the type of the method: Instance or Factory, then collect all methods with that type...
const ObjCInterfaceDecl * getClassInterface() const
Dataflow Directional Tag Classes.
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
bool isValid() const
Return true if this is a valid SourceLocation object.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD)
DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which backs the property is n...
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl * ActOnMethodDeclaration(Scope *S, SourceLocation BeginLoc, SourceLocation EndLoc, tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, ArrayRef< SourceLocation > SelectorLocs, Selector Sel, ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
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...
QualType getUnderlyingType() const
const ObjCProtocolList & getReferencedProtocols() const
TypeParamListContext
The context in which an Objective-C type parameter list occurs, for use in diagnostics.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
Represents the declaration of an Objective-C type parameter.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
static void CheckProtocolMethodDefs(Sema &S, SourceLocation ImpLoc, ObjCProtocolDecl *PDecl, bool &IncompleteImpl, const Sema::SelectorSet &InsMap, const Sema::SelectorSet &ClsMap, ObjCContainerDecl *CDecl, LazyProtocolNameSet &ProtocolsExplictImpl)
CheckProtocolMethodDefs - This routine checks unimplemented methods Declared in protocol, and those referenced by it.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
static bool matchTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, QualType leftQT, QualType rightQT)
bool hasObjCLifetime() const
IdentifierResolver IdResolver
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
Represents a pointer to an Objective C object.
static bool HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param)
HasExplicitOwnershipAttr - returns true when pointer to ObjC pointer has explicit ownership attribute...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
bool isIncompleteArrayType() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void setNext(ObjCMethodList *L)
static bool isMethodContextSameForKindofLookup(ObjCMethodDecl *Method, ObjCMethodDecl *MethodInList)
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
SourceLocation getSelectorLoc(unsigned Index) const
void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool IncompleteImpl=false)
ImplMethodsVsClassMethods - This is main routine to warn if any method remains unimplemented in the c...
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
bool isObjCQualifiedIdType() const
TypeSourceInfo * getTypeSourceInfo() const
DeclContext * getCurLexicalContext() const
static const TST TST_typename
param_const_iterator param_begin() const
Base for LValueReferenceType and RValueReferenceType.
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D)
Handle the specified top-level declaration that occurred inside and ObjC container.
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
A list of Objective-C protocols, along with the source locations at which they were referenced...
Wraps an ObjCPointerType with source location information.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class, its categories, and its super classes (using a linear search).
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
static void DiagnoseRetainableFlexibleArrayMember(Sema &S, ObjCInterfaceDecl *ID)
Diagnose attempts to use flexible array member with retainable object type.
static Sema::ResultTypeCompatibilityKind CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method, ObjCInterfaceDecl *CurrentClass)
Check whether the declared result type of the given Objective-C method declaration is compatible with...
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceManager & getSourceManager()
void setObjCMethodScopeInfo(unsigned parameterIndex)
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool hasMoreThanOneDecl() const
bool IsClassExtension() const
ImplementationControl getImplementationControl() const
RedeclarationKind forRedeclarationInCurContext()
SourceLocation getIdentifierLoc() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
ObjCInterfaceDecl * getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
bool isSet() const
Deprecated.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Reading or writing from this object requires a barrier call.
No particular method family.
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Decl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
Captures information about "declaration specifiers".
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
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...
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.
__DEVICE__ int min(int __a, int __b)
void ActOnObjCContainerFinishDefinition()
void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
A trivial tuple used to represent a source range.
bool hasUnrecoverableErrorOccurred() const
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
void setLexicalDeclContext(DeclContext *DC)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static SourceRange getTypeRange(TypeSourceInfo *TSI)
This represents a decl that may have a name.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
void setVariance(ObjCTypeParamVariance variance)
Set the variance of this type parameter.
void setTypeSourceInfo(TypeSourceInfo *newType)
Decl * ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CatName, SourceLocation CatLoc)
ActOnStartCategoryImplementation - Perform semantic checks on the category implementation declaration...
void DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl< ObjCMethodDecl *> &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass)
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
bool isPropertyAccessor() const
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
SourceLocation getLAngleLoc() const
static void diagnoseUseOfProtocols(Sema &TheSema, ObjCContainerDecl *CD, ObjCProtocolDecl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs)
void SetRangeEnd(SourceLocation Loc)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
ObjCContainerKind getObjCContainerKind() const
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
void setType(QualType newType)
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
unsigned size() const
Determine the number of type parameters in this list.
void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP)
CheckCategoryVsClassMethodMatches - Checks that methods implemented in category matches with those im...
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
The parameter is invariant: must match exactly.
void PushFunctionScope()
Enter a new function scope.
Decl * ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc, IdentifierInfo *AliasName, SourceLocation AliasLocation, IdentifierInfo *ClassName, SourceLocation ClassLocation)
ActOnCompatibilityAlias - this action is called after complete parsing of a @compatibility_alias decl...
SourceLocation getLocation() const
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
QualType getType() const
Return the type wrapped by this type source info.
ArrayRef< ParmVarDecl * > parameters() const
ObjCCompatibleAliasDecl - Represents alias of a class.
Helper class that creates diagnostics with optional template instantiation stacks.
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...