27 #include "llvm/ADT/DenseMap.h"
28 #include "llvm/ADT/DenseSet.h"
31 using namespace clang;
44 if (method->isInvalidDecl())
return true;
61 assert(resultClass &&
"unexpected object type!");
66 if (receiverTypeIfCall.
isNull() &&
67 !isa<ObjCImplementationDecl>(method->getDeclContext()))
75 if (isa<ObjCProtocolDecl>(method->getDeclContext())) {
76 if (receiverTypeIfCall.
isNull())
83 if (!receiverClass)
return false;
86 assert(receiverClass &&
"method not associated with a class!");
101 method->addAttr(UnavailableAttr::CreateImplicit(
Context,
"",
102 UnavailableAttr::IR_ARCInitReturnsUnrelated, loc));
107 Diag(loc, diag::err_arc_init_method_unrelated_result_type);
108 method->setInvalidDecl();
129 CurrentClass = Cat->getClassInterface();
130 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(DC))
131 CurrentClass = Impl->getClassInterface();
133 = dyn_cast<ObjCCategoryImplDecl>(DC))
134 CurrentClass = CatImpl->getClassInterface();
138 Diag(NewMethod->getLocation(),
139 diag::warn_related_result_type_compatibility_class)
144 Diag(NewMethod->getLocation(),
145 diag::warn_related_result_type_compatibility_protocol)
151 Diag(Overridden->getLocation(),
152 diag::note_related_result_type_family)
156 Diag(Overridden->getLocation(),
157 diag::note_related_result_type_overridden);
160 if ((NewMethod->hasAttr<NSReturnsRetainedAttr>() !=
161 Overridden->hasAttr<NSReturnsRetainedAttr>())) {
162 Diag(NewMethod->getLocation(),
163 diag::err_nsreturns_retained_attribute_mismatch) << 1;
164 Diag(Overridden->getLocation(), diag::note_previous_decl)
167 if ((NewMethod->hasAttr<NSReturnsNotRetainedAttr>() !=
168 Overridden->hasAttr<NSReturnsNotRetainedAttr>())) {
169 Diag(NewMethod->getLocation(),
170 diag::err_nsreturns_retained_attribute_mismatch) << 0;
171 Diag(Overridden->getLocation(), diag::note_previous_decl)
178 ni != ne && oi != oe; ++ni, ++oi) {
181 if (newDecl->hasAttr<NSConsumedAttr>() !=
182 oldDecl->hasAttr<NSConsumedAttr>()) {
183 Diag(newDecl->getLocation(),
184 diag::err_nsconsumed_attribute_mismatch);
185 Diag(oldDecl->getLocation(), diag::note_previous_decl)
212 Diag(method->getLocation(), diag::error_dealloc_bad_result_type)
216 Diag(method->getLocation(), diag::error_dealloc_bad_result_type)
228 method->addAttr(NSConsumesSelfAttr::CreateImplicit(
Context));
232 if (method->hasAttr<NSReturnsRetainedAttr>())
240 if (method->hasAttr<NSReturnsRetainedAttr>() ||
241 method->hasAttr<NSReturnsNotRetainedAttr>() ||
242 method->hasAttr<NSReturnsAutoreleasedAttr>())
247 method->addAttr(NSReturnsRetainedAttr::CreateImplicit(
Context));
255 if (ND && ND->isDeprecated()) {
256 S.
Diag(ImplLoc, diag::warn_deprecated_def) <<
select;
258 S.
Diag(ND->getLocation(), diag::note_method_declared_at)
261 S.
Diag(ND->getLocation(), diag::note_previous_decl) <<
"class";
327 if (!Param->isInvalidDecl() &&
330 Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
333 if (Param->getIdentifier())
344 Diag(MDecl->getLocation(), diag::err_arc_illegal_method_def)
376 ImplDeclOfMethodDecl = OID->getImplementation();
377 else if (
ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContDeclOfMethodDecl)) {
378 if (CD->IsClassExtension()) {
380 ImplDeclOfMethodDecl = OID->getImplementation();
382 ImplDeclOfMethodDecl = CD->getImplementation();
386 if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
388 dyn_cast<NamedDecl>(IMD),
389 MDecl->getLocation(), 0);
396 IC->getSuperClass() !=
nullptr;
397 }
else if (IC->hasDesignatedInitializers()) {
423 (SuperMethod && SuperMethod->hasAttr<ObjCRequiresSuperAttr>());
436 ObjCInterfaceValidatorCCC() : CurrentIDecl(nullptr) {}
438 : CurrentIDecl(IDecl) {}
440 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
454 unsigned NumProtoRefs,
459 for (
unsigned i = 0; i < NumProtoRefs; ++i) {
484 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(IDecl),
487 << SuperName << ClassName);
493 Diag(SuperLoc, diag::err_recursive_superclass)
494 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
498 dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
502 if (SuperClassDecl) {
507 if (PrevDecl && !SuperClassDecl) {
511 dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
512 QualType T = TDecl->getUnderlyingType();
532 if (!SuperClassDecl) {
533 Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
534 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
538 if (!dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
540 Diag(SuperLoc, diag::err_undef_superclass)
541 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
544 diag::err_forward_superclass,
547 SourceRange(AtInterfaceLoc, ClassLoc))) {
548 SuperClassDecl =
nullptr;
553 if (SuperClassType.isNull()) {
554 assert(!SuperClassDecl &&
"Failed to set SuperClassType?");
560 if (!SuperTypeArgs.empty()) {
568 SuperTypeArgsRange.
getEnd(),
580 if (!SuperClassTInfo) {
600 if (parsedTypeBound) {
611 diag::err_objc_type_param_bound_missing_pointer)
612 << typeBound << paramName
631 diag::err_objc_type_param_bound_nonobject)
632 << typeBound << paramName;
635 typeBoundInfo =
nullptr;
644 bool diagnosed =
false;
648 rangeToRemove = attr.getLocalSourceRange();
649 if (attr.getTypePtr()->getImmediateNullability()) {
650 Diag(attr.getLocStart(),
651 diag::err_objc_type_param_bound_explicit_nullability)
652 << paramName << typeBound
662 diag::err_objc_type_param_bound_qualified)
672 if (!quals.
empty()) {
682 if (!typeBoundInfo) {
689 index, paramLoc, paramName, colonLoc,
700 reinterpret_cast<ObjCTypeParamDecl * const *>(typeParamsIn.data()),
701 typeParamsIn.size());
707 llvm::SmallDenseMap<IdentifierInfo *, ObjCTypeParamDecl *> knownParams;
708 for (
auto typeParam : typeParams) {
709 auto known = knownParams.find(typeParam->getIdentifier());
710 if (known != knownParams.end()) {
711 Diag(typeParam->getLocation(), diag::err_objc_type_param_redecl)
712 << typeParam->getIdentifier()
715 typeParam->setInvalidDecl();
717 knownParams.insert(std::make_pair(typeParam->getIdentifier(), typeParam));
729 for (
auto typeParam : *typeParamList) {
730 if (!typeParam->isInvalidDecl()) {
756 if (prevTypeParams->
size() != newTypeParams->
size()) {
758 if (newTypeParams->
size() > prevTypeParams->
size()) {
759 diagLoc = newTypeParams->
begin()[prevTypeParams->
size()]->getLocation();
764 S.
Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
765 <<
static_cast<unsigned>(newContext)
766 << (newTypeParams->
size() > prevTypeParams->
size())
767 << prevTypeParams->
size()
768 << newTypeParams->
size();
774 for (
unsigned i = 0, n = prevTypeParams->
size(); i != n; ++i) {
781 newContext != TypeParamListContext::Definition) {
787 !(isa<ObjCInterfaceDecl>(prevTypeParam->getDeclContext()) &&
788 cast<ObjCInterfaceDecl>(prevTypeParam->getDeclContext())
800 auto diag = S.
Diag(diagLoc,
801 diag::err_objc_type_param_variance_conflict)
802 <<
static_cast<unsigned>(newTypeParam->
getVariance())
804 <<
static_cast<unsigned>(prevTypeParam->
getVariance())
813 StringRef newVarianceStr
820 (newVarianceStr +
" ").str());
829 S.
Diag(prevTypeParam->getLocation(), diag::note_objc_type_param_here)
847 S.
Diag(newBoundRange.
getBegin(), diag::err_objc_type_param_bound_conflict)
859 S.
Diag(prevTypeParam->getLocation(), diag::note_objc_type_param_here)
872 if (newContext == TypeParamListContext::ForwardDeclaration ||
873 newContext == TypeParamListContext::Definition) {
880 S.
Diag(newTypeParam->getLocation(),
881 diag::err_objc_type_param_bound_missing)
884 << (newContext == TypeParamListContext::ForwardDeclaration)
887 S.
Diag(prevTypeParam->getLocation(), diag::note_objc_type_param_here)
906 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
909 assert(ClassName &&
"Missing class identifier");
915 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
916 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
917 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
947 TypeParamListContext::Definition)) {
948 typeParamList =
nullptr;
951 Diag(ClassLoc, diag::err_objc_parameterized_forward_class_first)
953 Diag(prevTypeParamList->getLAngleLoc(), diag::note_previous_decl)
958 for (
auto typeParam : *prevTypeParamList) {
959 clonedTypeParams.push_back(
963 typeParam->getVariance(),
965 typeParam->getIndex(),
967 typeParam->getIdentifier(),
982 typeParamList, PrevIDecl, ClassLoc);
986 Diag(AtInterfaceLoc, diag::err_duplicate_class_def)
988 Diag(Def->getLocation(), diag::note_previous_definition);
989 IDecl->setInvalidDecl();
1007 ClassName, ClassLoc,
1008 SuperName, SuperLoc, SuperTypeArgs,
1009 SuperTypeArgsRange);
1017 NumProtoRefs, ProtoLocs);
1040 if (
const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) {
1041 QualType T = TDecl->getUnderlyingType();
1044 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end());
1059 Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
1060 Diag(ADecl->getLocation(), diag::note_previous_declaration);
1067 dyn_cast_or_null<TypedefNameDecl>(CDeclU)) {
1068 QualType T = TDecl->getUnderlyingType();
1071 ClassName = IDecl->getIdentifier();
1079 Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
1081 Diag(CDeclU->getLocation(), diag::note_previous_declaration);
1102 E = PList.
end();
I !=
E; ++
I) {
1105 if (PDecl->getIdentifier() == PName) {
1106 Diag(Ploc, diag::err_protocol_has_circular_dependency);
1107 Diag(PrevLoc, diag::note_previous_definition);
1111 if (!PDecl->hasDefinition())
1115 PDecl->getLocation(), PDecl->getReferencedProtocols()))
1126 Decl *
const *ProtoRefs,
1127 unsigned NumProtoRefs,
1133 assert(ProtocolName &&
"Missing protocol identifier");
1139 Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName;
1140 Diag(Def->getLocation(), diag::note_previous_definition);
1147 ProtocolLoc, AtProtoInterfaceLoc,
1149 PDecl->startDefinition();
1157 ProtocolName, ProtocolLoc, PrevDecl->getLocation(), PList);
1162 ProtocolLoc, AtProtoInterfaceLoc,
1176 if (!err && NumProtoRefs ) {
1179 NumProtoRefs, ProtoLocs);
1191 UndefinedProtocol = PDecl;
1197 UndefinedProtocol = PI;
1224 Diag(Pair.second, diag::err_undeclared_protocol) << Pair.first;
1233 if (!ForObjCContainer) {
1242 if (WarnOnDeclarations &&
1244 Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first;
1245 Diag(UndefinedProtocol->getLocation(), diag::note_protocol_decl_undefined)
1246 << UndefinedProtocol;
1248 Protocols.push_back(PDecl);
1259 ObjCTypeArgOrProtocolValidatorCCC(
ASTContext &context,
1261 :
Context(context), LookupKind(lookupKind) { }
1263 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
1283 if (
type->isObjCObjectPointerType() ||
1284 type->isBlockPointerType() ||
1285 type->isDependentType() ||
1286 type->isObjCObjectType())
1309 bool SelectProtocolFirst) {
1310 Diag(TypeArgLoc, diag::err_objc_type_args_and_protocols)
1311 << SelectProtocolFirst << TypeArgId << ProtocolId
1328 bool warnOnIncompleteProtocols) {
1331 unsigned numProtocolsResolved = 0;
1332 auto resolvedAsProtocols = [&] {
1333 assert(numProtocolsResolved == identifiers.size() &&
"Unresolved protocols");
1340 bool allAreTypeNames =
false;
1344 baseClass = objcObjectType->getInterface();
1346 if (
auto typeParams = baseClass->getTypeParamList()) {
1347 if (typeParams->size() == numProtocolsResolved) {
1349 allAreTypeNames =
true;
1356 for (
unsigned i = 0, n = protocols.size(); i != n; ++i) {
1361 if (!warnOnIncompleteProtocols) {
1373 if (warnOnIncompleteProtocols &&
1375 Diag(identifierLocs[i], diag::warn_undef_protocolref)
1377 Diag(forwardDecl->getLocation(), diag::note_protocol_decl_undefined)
1384 if (allAreTypeNames) {
1387 if (isa<ObjCInterfaceDecl>(
decl)) {
1389 firstClassNameLoc = identifierLocs[i];
1390 }
else if (!isa<TypeDecl>(
decl)) {
1392 allAreTypeNames =
false;
1395 allAreTypeNames =
false;
1404 if (allAreTypeNames && firstClassNameLoc.
isValid()) {
1405 llvm::SmallPtrSet<ObjCProtocolDecl*, 8> knownProtocols;
1407 bool allProtocolsDeclared =
true;
1408 for (
auto proto : protocols) {
1409 if (knownProtocols.count(static_cast<ObjCProtocolDecl *>(proto)) == 0) {
1410 allProtocolsDeclared =
false;
1415 if (allProtocolsDeclared) {
1416 Diag(firstClassNameLoc, diag::warn_objc_redundant_qualified_class_type)
1417 << baseClass->getDeclName() <<
SourceRange(lAngleLoc, rAngleLoc)
1423 protocolLAngleLoc = lAngleLoc;
1424 protocolRAngleLoc = rAngleLoc;
1425 assert(protocols.size() == identifierLocs.size());
1429 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1431 protocols.push_back(proto);
1433 ++numProtocolsResolved;
1437 if (numProtocolsResolved == identifiers.size())
1438 return resolvedAsProtocols();
1444 typedef llvm::PointerUnion<TypeDecl *, ObjCInterfaceDecl *> TypeOrClassDecl;
1446 unsigned numTypeDeclsResolved = 0;
1447 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1451 typeDecls.push_back(TypeOrClassDecl());
1455 if (
auto typeDecl = dyn_cast<TypeDecl>(decl)) {
1456 typeDecls.push_back(typeDecl);
1457 ++numTypeDeclsResolved;
1461 if (
auto objcClass = dyn_cast<ObjCInterfaceDecl>(decl)) {
1462 typeDecls.push_back(objcClass);
1463 ++numTypeDeclsResolved;
1467 typeDecls.push_back(TypeOrClassDecl());
1474 auto resolveTypeReference = [&](TypeOrClassDecl typeDecl,
SourceLocation loc)
1478 const char* prevSpec;
1481 if (
auto *actualTypeDecl = typeDecl.dyn_cast<
TypeDecl *>())
1511 Diag(loc, diag::err_objc_type_arg_missing_star)
1522 auto resolvedAsTypeDecls = [&] {
1526 assert(numTypeDeclsResolved == identifiers.size() &&
"Unresolved type decl");
1528 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1530 TypeResult type = resolveTypeReference(typeDecls[i], identifierLocs[i]);
1536 typeArgs.push_back(type.
get());
1539 typeArgsLAngleLoc = lAngleLoc;
1540 typeArgsRAngleLoc = rAngleLoc;
1545 if (numTypeDeclsResolved == identifiers.size())
1546 return resolvedAsTypeDecls();
1552 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1555 if (protocols[i] || typeDecls[i]) {
1561 if (protocols[i] && typeDecls[i])
1584 identifiers[i], identifierLocs[i],
1585 protocols[i] !=
nullptr);
1596 llvm::make_unique<ObjCTypeArgOrProtocolValidatorCCC>(
Context,
1603 PDiag(diag::err_undeclared_protocol_suggest)
1606 protocols[i] = proto;
1607 ++numProtocolsResolved;
1614 PDiag(diag::err_unknown_typename_suggest)
1617 typeDecls[i] = typeDecl;
1618 ++numTypeDeclsResolved;
1625 PDiag(diag::err_unknown_type_or_class_name_suggest)
1626 << identifiers[i] <<
true);
1628 typeDecls[i] = objcClass;
1629 ++numTypeDeclsResolved;
1635 Diag(identifierLocs[i],
1636 (lookupKind ==
LookupAnyName ? diag::err_objc_type_arg_missing
1638 : diag::err_unknown_typename))
1647 if (numProtocolsResolved == identifiers.size())
1648 return resolvedAsProtocols();
1651 assert(numTypeDeclsResolved == identifiers.size() &&
"Not all types?");
1652 return resolvedAsTypeDecls();
1663 llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
1664 for (
auto *MD : ID->
methods())
1665 MethodMap[MD->getSelector()] = MD;
1667 if (MethodMap.empty())
1669 for (
const auto *Method : CAT->
methods()) {
1670 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
1674 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
1675 << Method->getDeclName();
1676 Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
1693 IdentPair.second, AtProtocolLoc,
1705 DeclsInGroup.push_back(PDecl);
1717 Decl *
const *ProtoRefs,
1718 unsigned NumProtoRefs,
1728 diag::err_category_forward_interface,
1729 CategoryName ==
nullptr)) {
1734 ClassLoc, CategoryLoc, CategoryName,
1735 IDecl, typeParamList);
1736 CDecl->setInvalidDecl();
1740 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1745 Diag(ClassLoc, diag::err_class_extension_after_impl) << ClassName;
1747 diag::note_implementation_declared);
1755 Diag(CategoryLoc, diag::warn_dup_category_def)
1756 << ClassName << CategoryName;
1757 Diag(
Previous->getLocation(), diag::note_previous_definition);
1762 if (typeParamList) {
1767 : TypeParamListContext::Extension))
1768 typeParamList =
nullptr;
1771 diag::err_objc_parameterized_category_nonclass)
1772 << (CategoryName !=
nullptr)
1776 typeParamList =
nullptr;
1781 ClassLoc, CategoryLoc, CategoryName, IDecl,
1788 NumProtoRefs, ProtoLocs);
1819 CatIDecl->setImplicit();
1825 ClassLoc, AtCatImplLoc, CatLoc);
1828 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1829 CDecl->setInvalidDecl();
1831 diag::err_undef_interface)) {
1832 CDecl->setInvalidDecl();
1844 if (IDecl && IDecl->hasAttr<ObjCRuntimeVisibleAttr>()) {
1845 Diag(ClassLoc, diag::err_objc_runtime_visible_category)
1852 Diag(ClassLoc, diag::err_dup_implementation_category) << ClassName
1855 diag::note_previous_definition);
1856 CDecl->setInvalidDecl();
1862 dyn_cast<NamedDecl>(IDecl),
1863 CDecl->getLocation(), 2);
1881 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1882 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
1883 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
1884 }
else if ((IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl))) {
1888 diag::warn_undef_interface);
1894 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(),
CTK_NonError);
1900 PDiag(diag::warn_undef_interface_suggest) << ClassName,
1903 Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
1909 if (SuperClassname) {
1913 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1914 Diag(SuperClassLoc, diag::err_redefinition_different_kind)
1916 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
1918 SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
1922 Diag(SuperClassLoc, diag::err_undef_superclass)
1923 << SuperClassname << ClassName;
1927 Diag(SuperClassLoc, diag::err_conflicting_super_class)
1929 Diag(SDecl->getLocation(), diag::note_previous_definition);
1965 ClassLoc, AtClassImplLoc, SuperClassLoc);
1973 Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
1975 diag::note_previous_definition);
1976 IMPDecl->setInvalidDecl();
1983 dyn_cast<NamedDecl>(IDecl),
1984 IMPDecl->getLocation(), 1);
1990 IDecl->
getSuperClass()->hasAttr<ObjCRuntimeVisibleAttr>()) {
1991 Diag(ClassLoc, diag::err_objc_runtime_visible_subclass)
2002 DeclsInGroup.reserve(Decls.size() + 1);
2004 for (
unsigned i = 0, e = Decls.size(); i != e; ++i) {
2005 Decl *Dcl = Decls[i];
2008 if (Dcl->getDeclContext()->isFileContext())
2009 Dcl->setTopLevelDeclInObjCContainer();
2010 DeclsInGroup.push_back(Dcl);
2013 DeclsInGroup.push_back(ObjCImpDecl);
2021 assert(ImpDecl &&
"missing implementation decl");
2031 for (
unsigned i = 0, e = numIvars; i != e; ++i) {
2032 ivars[i]->setLexicalDeclContext(ImpDecl);
2043 assert(ivars &&
"missing @implementation ivars");
2046 Diag(ImpDecl->getLocation(), diag::warn_on_superclass_use);
2047 for (
unsigned i = 0; i < numIvars; i++) {
2051 Diag(ImplIvar->getLocation(), diag::err_duplicate_ivar_declaration);
2052 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2059 Diag(ImplIvar->getLocation(), diag::err_duplicate_ivar_declaration);
2060 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
2065 ImplIvar->setLexicalDeclContext(ImpDecl);
2077 for (; numIvars > 0 && IVI != IVE; ++IVI) {
2080 assert (ImplIvar &&
"missing implementation ivar");
2081 assert (ClsIvar &&
"missing class ivar");
2085 Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_type)
2088 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2093 diag::err_conflicting_ivar_bitwidth) << ImplIvar->
getIdentifier();
2095 diag::note_previous_definition);
2099 Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_name)
2101 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2107 Diag(ivars[j]->getLocation(), diag::err_inconsistent_ivar_count);
2108 else if (IVI != IVE)
2109 Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
2114 bool &IncompleteImpl,
2118 switch (method->getAvailability()) {
2144 S.
Diag(MethodLoc, diag::note_method_declared_at) << method;
2220 Decl::ObjCDeclQualifier y) {
2221 return (x & ~Decl::OBJC_TQ_CSNullability) !=
2222 (y & ~
Decl::OBJC_TQ_CSNullability);
2228 bool IsProtocolMethodDecl,
2229 bool IsOverridingMode,
2231 if (IsProtocolMethodDecl &&
2235 S.
Diag(MethodImpl->getLocation(),
2237 ? diag::warn_conflicting_overriding_ret_type_modifiers
2238 : diag::warn_conflicting_ret_type_modifiers))
2241 S.
Diag(MethodDecl->getLocation(), diag::note_previous_declaration)
2247 if (Warn && IsOverridingMode &&
2248 !isa<ObjCImplementationDecl>(MethodImpl->getDeclContext()) &&
2252 auto nullabilityMethodImpl =
2254 auto nullabilityMethodDecl =
2256 S.
Diag(MethodImpl->getLocation(),
2257 diag::warn_conflicting_nullability_attr_overriding_ret_types)
2259 nullabilityMethodImpl,
2263 nullabilityMethodDecl,
2266 S.
Diag(MethodDecl->getLocation(), diag::note_previous_declaration);
2276 IsOverridingMode ? diag::warn_conflicting_overriding_ret_types
2277 : diag::warn_conflicting_ret_types;
2293 IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types
2294 : diag::warn_non_covariant_ret_types;
2298 S.
Diag(MethodImpl->getLocation(), DiagID)
2302 S.
Diag(MethodDecl->getLocation(), IsOverridingMode
2303 ? diag::note_previous_declaration
2304 : diag::note_previous_definition)
2314 bool IsProtocolMethodDecl,
2315 bool IsOverridingMode,
2317 if (IsProtocolMethodDecl &&
2321 if (IsOverridingMode)
2322 S.
Diag(ImplVar->getLocation(),
2323 diag::warn_conflicting_overriding_param_modifiers)
2326 else S.
Diag(ImplVar->getLocation(),
2327 diag::warn_conflicting_param_modifiers)
2330 S.
Diag(IfaceVar->getLocation(), diag::note_previous_declaration)
2339 if (Warn && IsOverridingMode &&
2340 !isa<ObjCImplementationDecl>(MethodImpl->getDeclContext()) &&
2342 S.
Diag(ImplVar->getLocation(),
2343 diag::warn_conflicting_nullability_attr_overriding_param_types)
2352 S.
Diag(IfaceVar->getLocation(), diag::note_previous_declaration);
2360 IsOverridingMode ? diag::warn_conflicting_overriding_param_types
2361 : diag::warn_conflicting_param_types;
2377 IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types
2378 : diag::warn_non_contravariant_param_types;
2382 S.
Diag(ImplVar->getLocation(), DiagID)
2384 << MethodImpl->
getDeclName() << IfaceTy << ImplTy;
2385 S.
Diag(IfaceVar->getLocation(),
2386 (IsOverridingMode ? diag::note_previous_declaration
2387 : diag::note_previous_definition))
2398 if (implFamily == declFamily)
return false;
2406 if (impl->isInvalidDecl() || decl->isInvalidDecl())
return true;
2410 unsigned errorID = diag::err_arc_lost_method_convention;
2411 unsigned noteID = diag::note_arc_lost_method_convention;
2414 family = implFamily;
2415 errorID = diag::err_arc_gained_method_convention;
2416 noteID = diag::note_arc_gained_method_convention;
2420 enum FamilySelector {
2421 F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new
2423 FamilySelector familySelector = FamilySelector();
2426 case OMF_None: llvm_unreachable(
"logic error, no method convention");
2440 case OMF_init: familySelector = F_init;
break;
2441 case OMF_alloc: familySelector = F_alloc;
break;
2442 case OMF_copy: familySelector = F_copy;
break;
2444 case OMF_new: familySelector = F_new;
break;
2447 enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn };
2448 ReasonSelector reasonSelector;
2453 reasonSelector = R_UnrelatedReturn;
2455 reasonSelector = R_NonObjectReturn;
2458 S.
Diag(impl->getLocation(), errorID) <<
int(familySelector) << int(reasonSelector);
2459 S.
Diag(decl->getLocation(), noteID) <<
int(familySelector) << int(reasonSelector);
2466 bool IsProtocolMethodDecl) {
2472 IsProtocolMethodDecl,
false,
2478 IM != EM && IF != EF; ++IM, ++IF) {
2480 IsProtocolMethodDecl,
false,
true);
2484 Diag(ImpMethodDecl->getLocation(),
2485 diag::warn_conflicting_variadic);
2486 Diag(MethodDecl->getLocation(), diag::note_previous_declaration);
2492 bool IsProtocolMethodDecl) {
2495 IsProtocolMethodDecl,
true,
2501 IM != EM && IF != EF; ++IM, ++IF) {
2503 IsProtocolMethodDecl,
true,
true);
2507 Diag(Method->getLocation(),
2508 diag::warn_conflicting_overriding_variadic);
2509 Diag(Overridden->getLocation(), diag::note_previous_declaration);
2517 bool IsProtocolMethodDecl) {
2525 if (MethodDecl->hasAttr<UnavailableAttr>() ||
2526 MethodDecl->hasAttr<DeprecatedAttr>())
2530 IsProtocolMethodDecl,
false,
false);
2535 IM != EM && IF != EF; ++IM, ++IF) {
2538 IsProtocolMethodDecl,
false,
false);
2549 Diag(ImpMethodDecl->getLocation(),
2550 diag::warn_category_method_impl_match);
2551 Diag(MethodDecl->getLocation(), diag::note_method_declared_at)
2567 if (PDecl->hasAttr<ObjCExplicitProtocolImplAttr>())
2569 for (
const auto *PI : PDecl->
protocols())
2592 bool& IncompleteImpl,
2600 assert (IDecl &&
"CheckProtocolMethodDefs - IDecl is null");
2616 if (PDecl->hasAttr<ObjCExplicitProtocolImplAttr>()) {
2617 if (!ProtocolsExplictImpl) {
2622 ProtocolsExplictImpl->end())
2640 if (InsMap.count(fISelector))
2660 !method->isPropertyAccessor() &&
2661 !InsMap.count(method->getSelector()) &&
2677 IDecl->lookupMethod(method->getSelector(),
2681 if (C || MethodInClass->isPropertyAccessor())
2683 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2693 !ClsMap.count(method->getSelector()) &&
2700 if (C && IDecl->lookupMethod(method->getSelector(),
2706 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2715 CDecl, ProtocolsExplictImpl);
2727 bool &IncompleteImpl,
2728 bool ImmediateClass,
2729 bool WarnCategoryMethodImpl) {
2733 if (!InsMapSeen.insert(
I->getSelector()).second)
2735 if (!
I->isPropertyAccessor() &&
2736 !InsMap.count(
I->getSelector())) {
2739 diag::warn_undef_method_impl);
2745 "Expected to find the method through lookup as well");
2747 if (ImpMethodDecl) {
2748 if (!WarnCategoryMethodImpl)
2750 isa<ObjCProtocolDecl>(CDecl));
2751 else if (!
I->isPropertyAccessor())
2760 if (!ClsMapSeen.insert(
I->getSelector()).second)
2762 if (!
I->isPropertyAccessor() &&
2763 !ClsMap.count(
I->getSelector())) {
2766 diag::warn_undef_method_impl);
2771 "Expected to find the method through lookup as well");
2773 if (ImpMethodDecl) {
2774 if (!WarnCategoryMethodImpl)
2776 isa<ObjCProtocolDecl>(CDecl));
2777 else if (!
I->isPropertyAccessor())
2786 for (
auto *PI : PD->protocols())
2788 IMPDecl, PI, IncompleteImpl,
false,
2789 WarnCategoryMethodImpl);
2796 if (!WarnCategoryMethodImpl) {
2797 for (
auto *Cat :
I->visible_categories())
2799 IMPDecl, Cat, IncompleteImpl,
2800 ImmediateClass && Cat->IsClassExtension(),
2801 WarnCategoryMethodImpl);
2804 for (
auto *Ext :
I->visible_extensions())
2806 IMPDecl, Ext, IncompleteImpl,
false,
2807 WarnCategoryMethodImpl);
2811 for (
auto *PI :
I->all_referenced_protocols())
2813 IMPDecl, PI, IncompleteImpl,
false,
2814 WarnCategoryMethodImpl);
2818 if (!WarnCategoryMethodImpl &&
I->getSuperClass())
2821 I->getSuperClass(), IncompleteImpl,
false);
2852 if (SuperIDecl && SuperIDecl->
lookupMethod(Sel,
false))
2856 if (InsMap.empty() && ClsMap.empty())
2860 bool IncompleteImpl =
false;
2863 IncompleteImpl,
false,
2869 bool IncompleteImpl) {
2874 InsMap.insert(
I->getSelector());
2882 const auto *
P = PImpl->getPropertyDecl();
2885 InsMap.insert(
P->getGetterName());
2886 if (!
P->getSetterName().isNull())
2887 InsMap.insert(
P->getSetterName());
2894 bool SynthesizeProperties =
LangOpts.ObjCDefaultSynthProperties &&
2896 !IDecl->isObjCRequiresPropertyDefs();
2905 ClsMap.insert(
I->getSelector());
2912 IncompleteImpl,
true);
2917 dyn_cast<ObjCCategoryImplDecl>(IMPDecl))
2928 for (
auto *PI :
I->all_referenced_protocols())
2930 InsMap, ClsMap,
I, ExplicitImplProtocols);
2934 if (!C->IsClassExtension()) {
2935 for (
auto *
P : C->protocols())
2937 IncompleteImpl, InsMap, ClsMap, CDecl,
2938 ExplicitImplProtocols);
2943 llvm_unreachable(
"invalid ObjCContainerDecl type.");
2953 for (
unsigned i = 0; i != NumElts; ++i) {
2958 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
2968 Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
2969 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
2976 Diag(AtClassLoc, diag::warn_forward_class_redefinition)
2978 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
2986 = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
3008 if (PrevIDecl && TypeParams) {
3012 *
this, PrevTypeParams, TypeParams,
3013 TypeParamListContext::ForwardDeclaration)) {
3014 TypeParams =
nullptr;
3018 Diag(IdentLocs[i], diag::err_objc_parameterized_forward_class)
3021 Diag(Def->getLocation(), diag::note_defined_here)
3024 TypeParams =
nullptr;
3030 ClassName, TypeParams, PrevIDecl,
3036 DeclsInGroup.push_back(IDecl);
3044 const Type *left,
const Type *right);
3053 if (left == right)
return true;
3076 if (isa<VectorType>(left))
return isa<VectorType>(right);
3077 if (isa<VectorType>(right))
return false;
3100 return (leftSK == rightSK);
3106 assert(lt && rt && lt != rt);
3108 if (!isa<RecordType>(lt) || !isa<RecordType>(rt))
return false;
3109 RecordDecl *left = cast<RecordType>(lt)->getDecl();
3110 RecordDecl *right = cast<RecordType>(rt)->getDecl();
3116 if ((isa<CXXRecordDecl>(left) && !cast<CXXRecordDecl>(left)->isPOD()) ||
3117 (isa<CXXRecordDecl>(right) && !cast<CXXRecordDecl>(right)->isPOD()))
3132 for (; li != le && ri != re; ++li, ++ri) {
3133 if (!
matchTypes(Context, strategy, li->getType(), ri->getType()))
3136 return (li == le && ri == re);
3154 (left->hasAttr<NSReturnsRetainedAttr>()
3155 != right->hasAttr<NSReturnsRetainedAttr>() ||
3156 left->hasAttr<NSConsumesSelfAttr>()
3157 != right->hasAttr<NSConsumesSelfAttr>()))
3164 for (; li != le && ri != re; ++li, ++ri) {
3165 assert(ri != right->
param_end() &&
"Param mismatch");
3172 lparm->hasAttr<NSConsumedAttr>() != rparm->hasAttr<NSConsumedAttr>())
3180 auto *MethodProtocol = dyn_cast<
ObjCProtocolDecl>(Method->getDeclContext());
3181 auto *MethodInListProtocol =
3185 if ((MethodProtocol && !MethodInListProtocol) ||
3186 (!MethodProtocol && MethodInListProtocol))
3189 if (MethodProtocol && MethodInListProtocol)
3195 return MethodInterface == MethodInListInterface;
3203 dyn_cast<ObjCCategoryDecl>(Method->getDeclContext()))
3204 if (!CD->IsClassExtension() && List->
getBits() < 2)
3218 for (; List; Previous = List, List = List->
getNext()) {
3235 if (!SameDeclaration ||
3241 List->setHasMoreThanOneDecl(
true);
3245 if (Method->isDeprecated() && SameDeclaration &&
3246 !ListWithSameDeclaration && !List->
getMethod()->isDeprecated())
3247 ListWithSameDeclaration = List;
3249 if (Method->isUnavailable() && SameDeclaration &&
3250 !ListWithSameDeclaration &&
3252 ListWithSameDeclaration = List;
3266 List->setHasMoreThanOneDecl(
true);
3271 if (Method->isDeprecated()) {
3272 if (!PrevObjCMethod->isDeprecated())
3273 List->setMethod(Method);
3277 if (Method->isUnavailable()) {
3279 List->setMethod(Method);
3290 if (ListWithSameDeclaration) {
3293 ListWithSameDeclaration->
setMethod(Method);
3294 ListWithSameDeclaration->
setNext(List);
3304 assert(ExternalSource &&
"We need an external AST source");
3309 if (!ExternalSource)
3314 void Sema::AddMethodToGlobalPool(
ObjCMethodDecl *Method,
bool impl,
3317 if (cast<Decl>(Method->getDeclContext())->isInvalidDecl())
3330 ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
3364 assert(BoundInterface &&
"unexpected object type!");
3368 auto *MethodProtocol = dyn_cast<
ObjCProtocolDecl>(Method->getDeclContext());
3369 if (MethodProtocol) {
3379 return MethodInterface == BoundInterface ||
3380 MethodInterface->isSuperClassOf(BoundInterface) ||
3381 BoundInterface->isSuperClassOf(MethodInterface);
3383 llvm_unreachable(
"unknow method context");
3390 bool InstanceFirst,
bool CheckTheOther,
3403 if (M->getMethod() && !M->getMethod()->isHidden()) {
3405 Methods.push_back(M->getMethod());
3409 if (!Methods.empty())
3410 return Methods.size() > 1;
3419 if (M->getMethod() && !M->getMethod()->isHidden()) {
3421 Methods.push_back(M->getMethod());
3424 return Methods.size() > 1;
3432 FilteredMethods.push_back(BestMethod);
3434 for (
auto *M : Methods)
3435 if (M != BestMethod && !M->hasAttr<UnavailableAttr>())
3436 FilteredMethods.push_back(M);
3438 if (FilteredMethods.size() > 1)
3453 bool receiverIdOrClass,
3463 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
3466 if (M->getMethod() && !M->getMethod()->isHidden())
3467 return M->getMethod();
3474 bool receiverIdOrClass) {
3476 bool issueDiagnostic =
false, issueError =
false;
3480 bool strictSelectorMatch =
3481 receiverIdOrClass &&
3483 if (strictSelectorMatch) {
3484 for (
unsigned I = 1, N = Methods.size();
I != N; ++
I) {
3486 issueDiagnostic =
true;
3495 if (!strictSelectorMatch ||
3496 (issueDiagnostic &&
getLangOpts().ObjCAutoRefCount))
3497 for (
unsigned I = 1, N = Methods.size();
I != N; ++
I) {
3501 issueDiagnostic =
true;
3508 if (issueDiagnostic) {
3510 Diag(R.
getBegin(), diag::err_arc_multiple_method_decl) << Sel << R;
3511 else if (strictSelectorMatch)
3512 Diag(R.
getBegin(), diag::warn_strict_multiple_method_decl) << Sel << R;
3514 Diag(R.
getBegin(), diag::warn_multiple_method_decl) << Sel << R;
3516 Diag(Methods[0]->getLocStart(),
3517 issueError ? diag::note_possibility : diag::note_using)
3518 << Methods[0]->getSourceRange();
3519 for (
unsigned I = 1, N = Methods.size();
I != N; ++
I) {
3520 Diag(Methods[
I]->getLocStart(), diag::note_also_found)
3521 << Methods[
I]->getSourceRange();
3533 Method = Method->getNext())
3534 if (Method->getMethod() &&
3537 return Method->getMethod();
3540 Method = Method->getNext())
3541 if (Method->getMethod() &&
3544 return Method->getMethod();
3556 unsigned MinPossibleEditDistance =
abs((
int)MethodName.size() - (int)Typo.size());
3557 if (MinPossibleEditDistance > 0 &&
3558 Typo.size() / MinPossibleEditDistance < 1)
3560 unsigned EditDistance = Typo.edit_distance(MethodName,
true, MaxEditDistance);
3561 if (EditDistance > MaxEditDistance)
3563 if (EditDistance == BestEditDistance)
3564 BestMethod.push_back(Method);
3565 else if (EditDistance < BestEditDistance) {
3567 BestMethod.push_back(Method);
3586 bool ObjectIsId =
true, ObjectIsClass =
true;
3588 ObjectIsId = ObjectIsClass =
false;
3593 ObjectType =
QualType(ObjCPtr->getInterfaceType(), 0);
3594 ObjectIsId = ObjectIsClass =
false;
3597 ObjectIsClass =
false;
3607 if (M->getMethod() &&
3608 (M->getMethod()->getSelector().getNumArgs() ==
NumArgs) &&
3609 (M->getMethod()->getSelector() != Sel)) {
3611 Methods.push_back(M->getMethod());
3612 else if (!ObjectIsClass &&
3615 Methods.push_back(M->getMethod());
3619 if (M->getMethod() &&
3620 (M->getMethod()->getSelector().getNumArgs() ==
NumArgs) &&
3621 (M->getMethod()->getSelector() != Sel)) {
3623 Methods.push_back(M->getMethod());
3624 else if (!ObjectIsId &&
3627 Methods.push_back(M->getMethod());
3632 for (
unsigned i = 0, e = Methods.size(); i < e; i++) {
3636 return (SelectedMethods.size() == 1) ? SelectedMethods[0] :
nullptr;
3646 for (
auto *Ivar : ID->
ivars()) {
3647 if (Ivar->isInvalidDecl())
3652 Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
3653 Diag(prevIvar->getLocation(), diag::note_previous_declaration);
3654 Ivar->setInvalidDecl();
3666 if (ivar->isInvalidDecl())
continue;
3669 S.
Diag(ivar->getLocation(), diag::err_arc_weak_disabled);
3671 S.
Diag(ivar->getLocation(), diag::err_arc_weak_no_runtime);
3679 case Decl::ObjCInterface:
3681 case Decl::ObjCProtocol:
3683 case Decl::ObjCCategory:
3684 if (cast<ObjCCategoryDecl>(
CurContext)->IsClassExtension())
3687 case Decl::ObjCImplementation:
3689 case Decl::ObjCCategoryImpl:
3703 assert(AtEnd.
isValid() &&
"Invalid location for '@end'");
3706 Decl *ClassDecl = cast<Decl>(OCD);
3708 bool isInterfaceDeclKind =
3709 isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl)
3710 || isa<ObjCProtocolDecl>(ClassDecl);
3711 bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
3714 llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap;
3715 llvm::DenseMap<Selector, const ObjCMethodDecl*> ClsMap;
3717 for (
unsigned i = 0, e = allMethods.size(); i != e; i++ ) {
3719 cast_or_null<ObjCMethodDecl>(allMethods[i]);
3721 if (!Method)
continue;
3727 if ((isInterfaceDeclKind && PrevMethod && !match)
3728 || (checkIdenticalMethods && match)) {
3729 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
3731 Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
3732 Method->setInvalidDecl();
3737 Method->getLocation()))
3738 Diag(Method->getLocation(), diag::warn_duplicate_method_decl)
3740 Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
3751 if ((isInterfaceDeclKind && PrevMethod && !match)
3752 || (checkIdenticalMethods && match)) {
3753 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
3755 Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
3756 Method->setInvalidDecl();
3761 Method->getLocation()))
3762 Diag(Method->getLocation(), diag::warn_duplicate_method_decl)
3764 Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
3771 if (isa<ObjCInterfaceDecl>(ClassDecl)) {
3778 if (C->IsClassExtension()) {
3784 if (CDecl->getIdentifier())
3788 for (
auto *
I : CDecl->properties())
3790 CDecl->setAtEndRange(AtEnd);
3793 IC->setAtEndRange(AtEnd);
3800 for (
const auto *Ext : IDecl->visible_extensions()) {
3801 for (
const auto *
Property : Ext->instance_properties()) {
3804 = IC->FindPropertyImplDecl(
Property->getIdentifier(),
3806 if (PIDecl->getPropertyImplementation()
3810 for (
const auto *Ext : IDecl->visible_extensions()) {
3812 = Ext->getInstanceMethod(
Property->getGetterName()))
3813 GetterMethod->setPropertyAccessor(
true);
3816 = Ext->getInstanceMethod(
Property->getSetterName()))
3817 SetterMethod->setPropertyAccessor(
true);
3825 if (IDecl->hasDesignatedInitializers())
3829 bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>();
3830 if (IDecl->getSuperClass() ==
nullptr) {
3833 if (!HasRootClassAttr) {
3836 Diag(DeclLoc, diag::warn_objc_root_class_missing)
3837 << IDecl->getIdentifier();
3844 if (NSObjectDecl && NSObjectDecl->getDefinition()) {
3845 Diag(SuperClassLoc, diag::note_objc_needs_superclass)
3848 Diag(SuperClassLoc, diag::note_objc_needs_superclass);
3851 }
else if (HasRootClassAttr) {
3853 Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass);
3857 while (IDecl->getSuperClass()) {
3859 IDecl = IDecl->getSuperClass();
3865 dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
3866 CatImplClass->setAtEndRange(AtEnd);
3872 = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier())) {
3877 if (isInterfaceDeclKind) {
3879 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
3882 if (
VarDecl *VDecl = dyn_cast<VarDecl>(*
I)) {
3883 if (!VDecl->hasExternalStorage())
3884 Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass);
3890 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
3893 (*I)->setTopLevelDeclInObjCContainer();
3903 static Decl::ObjCDeclQualifier
3905 return (Decl::ObjCDeclQualifier) (
unsigned) PQTVal;
3922 if (ResultObjectType->isObjCIdType() ||
3923 ResultObjectType->isObjCQualifiedIdType())
3928 = ResultObjectType->getInterfaceDecl()) {
3934 if (ResultClass->isSuperClassOf(CurrentClass))
3950 class OverrideSearch {
3954 llvm::SmallPtrSet<ObjCMethodDecl*, 4> Overridden;
3977 = cast<ObjCContainerDecl>(method->getDeclContext());
3983 searchFromContainer(container);
3985 searchFromContainer(Interface);
3987 searchFromContainer(container);
3997 if (container->isInvalidDecl())
return;
4000 #define OBJCCONTAINER(type, base) \
4002 searchFrom(cast<type##Decl>(container)); \
4004 #define ABSTRACT_DECL(expansion)
4005 #define DECL(type, base) \
4007 #include "clang/AST/DeclNodes.inc"
4008 llvm_unreachable(
"not an ObjC container!");
4081 Overridden.insert(meth);
4091 searchFromContainer(container);
4100 OverrideSearch overrides(*
this, ObjCMethod);
4106 bool hasOverriddenMethodsInBaseOrProtocol =
false;
4107 for (OverrideSearch::iterator
4108 i = overrides.begin(), e = overrides.end(); i != e; ++i) {
4111 if (!hasOverriddenMethodsInBaseOrProtocol) {
4112 if (isa<ObjCProtocolDecl>(overridden->getDeclContext()) ||
4115 hasOverriddenMethodsInBaseOrProtocol =
true;
4117 }
else if (isa<ObjCImplDecl>(ObjCMethod->getDeclContext())) {
4130 unsigned CategCount = List.
getBits();
4131 if (CategCount > 0) {
4134 if (CategCount > 1 ||
4135 !isa<ObjCCategoryImplDecl>(overridden->getDeclContext())) {
4136 OverrideSearch overrides(*
this, overridden);
4137 for (OverrideSearch::iterator
4138 OI= overrides.begin(), OE= overrides.end(); OI!=OE; ++OI) {
4140 if (isa<ObjCProtocolDecl>(SuperOverridden->getDeclContext()) ||
4142 hasOverriddenMethodsInBaseOrProtocol =
true;
4160 if (ObjCMethod->isImplicit() && overridden->isImplicit())
4164 if (isa<ObjCInterfaceDecl>(ObjCMethod->getDeclContext()) ||
4165 isa<ObjCImplementationDecl>(ObjCMethod->getDeclContext()))
4167 isa<ObjCProtocolDecl>(overridden->getDeclContext()));
4169 if (CurrentClass && overridden->getDeclContext() != CurrentClass &&
4170 isa<ObjCInterfaceDecl>(overridden->getDeclContext()) &&
4171 !overridden->isImplicit() ) {
4176 for (; ParamI !=
E && PrevI != PrevE; ++ParamI, ++PrevI) {
4177 assert(PrevI != overridden->
param_end() &&
"Param mismatch");
4183 Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
4185 Diag(overridden->getLocation(), diag::note_previous_declaration);
4192 ObjCMethod->
setOverriding(hasOverriddenMethodsInBaseOrProtocol);
4202 bool prevUsesCSKeyword) {
4208 if (nullability.hasValue() == prevNullability.hasValue()) {
4214 if (*nullability == *prevNullability)
4218 S.
Diag(loc, diag::err_nullability_conflicting)
4241 if (prevMethod->hasAttr<ObjCRequiresSuperAttr>() &&
4242 !method->hasAttr<ObjCRequiresSuperAttr>()) {
4245 ObjCRequiresSuperAttr::CreateImplicit(S.
Context,
4246 method->getLocation()));
4262 unsigned numPrevParams = prevMethod->
param_size();
4263 for (
unsigned i = 0, n =
std::min(numParams, numPrevParams); i != n; ++i) {
4270 S, param->getLocation(), param->
getType(),
4272 prevParam->getLocation(), prevParam->
getType(),
4290 bool isVariadic,
bool MethodDefinition) {
4293 Diag(MethodLoc, diag::error_missing_method_context);
4297 Decl *ClassDecl = cast<Decl>(OCD);
4300 bool HasRelatedResultType =
false;
4308 QualType bareResultType = resultDeclType;
4313 Diag(MethodLoc, diag::warn_missing_method_return_type)
4319 MethodType == tok::minus, isVariadic,
4324 HasRelatedResultType);
4328 for (
unsigned i = 0, e = Sel.
getNumArgs(); i != e; ++i) {
4332 if (!ArgInfo[i].
Type) {
4345 Diag(ArgInfo[i].NameLoc,
4346 (MethodDefinition ? diag::warn_method_param_redefinition
4347 : diag::warn_method_param_declaration))
4349 Diag(PrevDecl->getLocation(),
4350 diag::note_previous_declaration);
4359 ArgInfo[i].NameLoc, ArgInfo[i].Name,
4370 if (Param->hasAttr<BlocksAttr>()) {
4371 Diag(Param->getLocation(), diag::err_block_on_nonlocal);
4372 Param->setInvalidDecl();
4377 Params.push_back(Param);
4380 for (
unsigned i = 0, e = CNumArgs; i != e; ++i) {
4383 if (ArgType.isNull())
4389 Param->setDeclContext(ObjCMethod);
4390 Params.push_back(Param);
4402 if (
ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(ClassDecl)) {
4403 if (MethodType == tok::minus) {
4404 PrevMethod = ImpDecl->getInstanceMethod(Sel);
4405 ImpDecl->addInstanceMethod(ObjCMethod);
4407 PrevMethod = ImpDecl->getClassMethod(Sel);
4408 ImpDecl->addClassMethod(ObjCMethod);
4414 if (
auto *IMD = IDecl->lookupMethod(ObjCMethod->
getSelector(),
4419 if (isa<ObjCCategoryImplDecl>(ImpDecl) && IMD->isOverriding() &&
4421 Diag(ObjCMethod->getLocation(), diag::warn_dealloc_in_category)
4427 cast<DeclContext>(ClassDecl)->addDecl(ObjCMethod);
4432 Diag(ObjCMethod->getLocation(), diag::err_duplicate_method_decl)
4434 Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
4435 ObjCMethod->setInvalidDecl();
4443 if (!CurrentClass) {
4445 CurrentClass = Cat->getClassInterface();
4446 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(ClassDecl))
4447 CurrentClass = Impl->getClassInterface();
4449 = dyn_cast<ObjCCategoryImplDecl>(ClassDecl))
4450 CurrentClass = CatImpl->getClassInterface();
4458 bool ARCError =
false;
4465 LangOpts.ObjCInferRelatedResultType) {
4466 bool InferRelatedResultType =
false;
4492 if (InferRelatedResultType &&
4513 Diag(D->getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
4514 D->setInvalidDecl();
4527 Diag(DeclStart, diag::err_undef_interface) << ClassName;
4531 Diag(DeclStart, diag::err_atdef_nonfragile_interface);
4539 for (
unsigned i = 0; i < Ivars.size(); i++) {
4547 Decls.push_back(FD);
4552 D != Decls.end(); ++D) {
4556 else if (
RecordDecl *Record = dyn_cast<RecordDecl>(TagD))
4557 Record->addDecl(FD);
4572 Diag(IdLoc, diag::err_arg_with_address_space);
4584 Diag(IdLoc ,diag::err_catch_param_not_objc_type);
4587 Diag(IdLoc, diag::err_illegal_qualifiers_on_catch_parm);
4599 New->setInvalidDecl();
4620 diag::err_invalid_thread)
4644 New->setInvalidDecl();
4654 if (New->hasAttr<BlocksAttr>())
4655 Diag(New->getLocation(), diag::err_block_on_nonlocal);
4667 Ivars.push_back(Iv);
4673 if (ExternalSource) {
4676 for (
unsigned I = 0, N = Sels.size();
I != N; ++
I)
4687 Selector Sel = SelectorAndLocation.first;
4690 Diag(Loc, diag::warn_unimplemented_selector) << Sel;
4713 IV->getIdentifier());
4722 class UnusedBackingIvarChecker :
4729 bool InvokedSelfMethod;
4733 : S(S), Method(Method), IvarD(IvarD),
4734 AccessedIvar(
false), InvokedSelfMethod(
false) {
4740 AccessedIvar =
true;
4749 InvokedSelfMethod =
true;
4762 unsigned DIAG = diag::warn_unused_property_backing_ivar;
4772 UnusedBackingIvarChecker Checker(*
this, CurMethod, IV);
4773 Checker.TraverseStmt(CurMethod->getBody());
4774 if (Checker.AccessedIvar)
4781 if (!IV->isReferenced() || !Checker.InvokedSelfMethod) {
4782 Diag(Loc, DIAG) << IV;
4783 Diag(PDecl->getLocation(), diag::note_property_declare);
SourceLocation getThreadStorageClassSpecLoc() const
unsigned getAddressSpace() const
Return the address space of this type.
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...
param_const_iterator param_begin() const
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method's parameters and selector source locations.
bool hasDefinition() const
Determine whether this class has been defined.
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
static bool tryMatchRecordTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, const Type *left, const Type *right)
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, ObjCInterfaceDecl *ID)
DiagnoseClassExtensionDupMethods - Check for duplicate declaration of a class method in its extension...
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
static Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
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)
protocol_range protocols() const
Smart pointer class that efficiently represents Objective-C method names.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isObjCContainer() const
ImplementationControl getImplementationControl() const
Simple class containing the result of Sema::CorrectTypo.
void setStarLoc(SourceLocation Loc)
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.
ObjCInterfaceDecl * getClassInterface()
ObjCInterfaceDecl * getClassInterface()
DeclContext * getCurLexicalContext() const
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 isBitField() const
Determines whether this field is a bitfield.
static QualType getObjectType(APValue::LValueBase B)
Retrieves the "underlying object type" of the given expression, as used by __builtin_object_size.
llvm::DenseSet< IdentifierInfo * > ProtocolNameSet
FIXME: Type hierarchies in Objective-C can be deep.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
const LangOptions & getLangOpts() const
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
Look up the name of an Objective-C protocol.
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
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
void DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl< ObjCMethodDecl * > &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass)
__DEVICE__ long long abs(long long __n)
Captures information about "declaration specifiers" specific to Objective-C.
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)
SCS getStorageClassSpec() const
std::string getAsString() const
bool CheckForwardProtocolDeclarationForCircularDependency(IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, const ObjCList< ObjCProtocolDecl > &PList)
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, AttributeList *attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
The base class of the type hierarchy.
bool isObjCQualifiedClassType() const
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
virtual void updateOutOfDateSelector(Selector Sel)
Load the contents of the global method pool for a given selector if necessary.
The parameter is covariant, e.g., X<T> is a subtype of X<U> when the type parameter is covariant and ...
virtual void ReadMethodPool(Selector Sel)
Load the contents of the global method pool for a given selector.
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
ObjCDeclQualifier getObjCDeclQualifier() const
SourceLocation getInlineSpecLoc() 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...
static void HelperSelectorsForTypoCorrection(SmallVectorImpl< const ObjCMethodDecl * > &BestMethod, StringRef Typo, const ObjCMethodDecl *Method)
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implict parameters. ...
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group, bool TypeMayContainAuto=true)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
void setImplementation(ObjCCategoryImplDecl *ImplD)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Information about one declarator, including the parsed type information and the identifier.
DiagnosticsEngine & Diags
SourceLocation getLocStart() const LLVM_READONLY
std::string getAsString() const
field_iterator field_begin() const
static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc, ObjCMethodDecl *method, bool &IncompleteImpl, unsigned DiagID, NamedDecl *NeededFor=nullptr)
ObjCMethodDecl - Represents an instance or class method declaration.
SourceRange getReturnTypeSourceRange() const
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
unsigned param_size() const
unsigned size() const
Determine the number of type parameters in this list.
ParmVarDecl - Represents a parameter to a function.
static void DiagnoseObjCImplementedDeprecations(Sema &S, NamedDecl *ND, SourceLocation ImplLoc, int select)
The collection of all-type qualifiers we support.
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods=None, ArrayRef< DeclGroupPtrTy > allTUVars=None)
Base wrapper for a particular "section" of type source info.
RecordDecl - Represents a struct/union/class.
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
bool isScalarType() const
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList * > TypeParamLists, unsigned NumElts)
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
ObjCMethodFamily
A family of Objective-C methods.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
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)
bool isOverriding() const
Whether this method overrides any other in the class hierarchy.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
ImplicitParamDecl * getCmdDecl() const
all_protocol_range all_referenced_protocols() const
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.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void setSuperClass(TypeSourceInfo *superClass)
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
method_range methods() const
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.
void startDefinition()
Starts the definition of this Objective-C protocol.
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...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
static bool FilterMethodsByTypeBound(ObjCMethodDecl *Method, const ObjCObjectType *TypeBound)
Return true if the given method is wthin the type bound.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
llvm::BumpPtrAllocator BumpAlloc
SourceLocation getBeginLoc() const
Get the begin source location.
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, IdentifierInfo *ClassName, SmallVectorImpl< Decl * > &Decls)
Called whenever @defs(ClassName) is encountered in the source.
bool IsClassExtension() const
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)
SourceLocation getSelectorLoc(unsigned Index) const
Represents the results of name lookup.
ObjCMethodDecl * LookupImplementedMethodInGlobalPool(Selector Sel)
LookupImplementedMethodInGlobalPool - Returns the method which has an implementation.
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)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
ObjCContainerDecl - Represents a container for method declarations.
const LangOptions & getLangOpts() const
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
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())
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void ActOnTypedefedProtocols(SmallVectorImpl< Decl * > &ProtocolRefs, IdentifierInfo *SuperName, SourceLocation SuperLoc)
ActOnTypedefedProtocols - this action finds protocol list as part of the typedef'ed use for a qualifi...
SCS
storage-class-specifier
Decl * ActOnObjCContainerStartDefinition(Decl *IDecl)
void RemoveDecl(NamedDecl *D)
RemoveDecl - Unlink the decl from its shadowed decl chain.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
TypeDecl - Represents a declaration of a type.
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
void setExceptionVariable(bool EV)
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
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)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Decl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, AttributeList *AttrList)
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod)
bool hasUnrecoverableErrorOccurred() const
Represents an Objective-C protocol declaration.
bool isObjCIndependentClassType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
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)
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
A class that does preordor or postorder depth-first traversal on the entire Clang AST and visits each...
Represents an ObjC class declaration.
bool CollectMultipleMethodsInGlobalPool(Selector Sel, SmallVectorImpl< ObjCMethodDecl * > &Methods, bool InstanceFirst, bool CheckTheOther, const ObjCObjectType *TypeBound=nullptr)
Returns instance or factory methods in global method pool for given selector.
propimpl_range property_impls() const
ObjCMethodDecl * getMethod() const
detail::InMemoryDirectory::const_iterator I
virtual void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation > > &Sels)
Read the set of referenced selectors known to the external Sema source.
known_categories_range known_categories() const
const LangOptions & LangOpts
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, bool IncludeCXX11Attributes=true)
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
SourceRange getRange() const
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.
ObjCProtocolDecl *const * iterator
field_iterator field_end() const
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)
static Decl::ObjCDeclQualifier CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal)
CvtQTToAstBitMask - utility routine to produce an AST bitmask for objective-c's type qualifier from t...
static const Decl * getDefinition(const Decl *D)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
static bool isAcceptableMethodMismatch(ObjCMethodDecl *chosen, ObjCMethodDecl *other)
Determines if this is an "acceptable" loose mismatch in the global method pool.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
const ParmVarDecl *const * param_const_iterator
Sema - This implements semantic analysis and AST building for C.
SourceLocation getLocStart() const LLVM_READONLY
ResultTypeCompatibilityKind
Describes the compatibility of a result type with its method.
llvm::SmallPtrSet< Selector, 8 > SelectorSet
bool inferObjCARCLifetime(ValueDecl *decl)
void SetRangeStart(SourceLocation Loc)
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
ObjCDeclQualifier getObjCDeclQualifier() const
void ActOnSuperClassOfClassInterface(Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange)
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.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isUnarySelector() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
Type source information for an attributed type.
LookupNameKind
Describes the kind of name lookup to perform.
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...
unsigned getNumArgs() const
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
bool isObjCClassType() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
TypeResult ActOnTypeName(Scope *S, Declarator &D)
Expr * getBitWidth() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
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.
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
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...
ParmVarDecl *const * param_iterator
ImplicitParamDecl * getSelfDecl() const
void setDefined(bool isDefined)
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
bool isObjCIdType() const
ObjCTypeParamDecl * back() const
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.
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
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)
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
static void DiagnoseWeakIvars(Sema &S, ObjCImplementationDecl *ID)
Diagnose attempts to define ARC-__weak ivars when __weak is disabled.
bool isInstanceMethod() const
clang::ObjCRuntime ObjCRuntime
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
QualType getObjCIdType() const
Represents the Objective-CC id type.
An expression that sends a message to the given Objective-C object or class.
void WarnConflictingTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId, SourceLocation ProtocolLoc, IdentifierInfo *TypeArgId, SourceLocation TypeArgLoc, bool SelectProtocolFirst=false)
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
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...
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
SourceLocation getStorageClassSpecLoc() const
void removeCVRQualifiers(unsigned mask)
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl * > Decls)
TypeSourceInfo * getTypeSourceInfo() const
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
const clang::PrintingPolicy & getPrintingPolicy() const
ivar_iterator ivar_begin() const
bool hasObjCLifetime() const
ObjCCategoryDecl * getCategoryDecl() const
param_const_iterator param_end() const
SourceLocation getEndLoc() const
Get the end source location.
bool isClassMethod() const
ArrayRef< ParmVarDecl * > parameters() const
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)
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
SelectorTable & Selectors
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
static void findProtocolsWithExplicitImpls(const ObjCProtocolDecl *PDecl, ProtocolNameSet &PNS)
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
const TemplateArgument * iterator
unsigned getBitWidthValue(const ASTContext &Ctx) const
Interfaces are the core concept in Objective-C for object oriented design.
ivar_iterator ivar_end() const
bool isValid() const
Return true if this is a valid SourceLocation object.
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...
void setObjCDeclQualifier(ObjCDeclQualifier QV)
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
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.
static bool objcModifiersConflict(Decl::ObjCDeclQualifier x, Decl::ObjCDeclQualifier y)
Determine whether two set of Objective-C declaration qualifiers conflict.
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.
ObjCTypeParamList * actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef< Decl * > typeParams, SourceLocation rAngleLoc)
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.
const ObjCInterfaceDecl * getClassInterface() const
bool isPropertyAccessor() const
ObjCIvarDecl * GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, const ObjCPropertyDecl *&PDecl) const
GetIvarBackingPropertyAccessor - If method is a property setter/getter and it property has a backing ...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Look up any declaration with any name.
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.
std::string getAsString() const
Derive the full selector name (e.g.
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.
SourceLocation getBegin() const
QualType getReturnType() const
const T * castAs() const
Member-template castAs<specific type>.
void updateOutOfDateSelector(Selector Sel)
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
char __ovld __cnfn select(char a, char b, char c)
For each component of a vector type, result[i] = if MSB of c[i] is set ? b[i] : a[i].
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...
sema::FunctionScopeInfo * getCurFunction() const
void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList)
static bool HelperIsMethodInObjCType(Sema &S, Selector Sel, QualType ObjectType)
SourceLocation getLAngleLoc() const
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
QualType getType() const
Return the type wrapped by this type source info.
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.
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()
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
ObjCDeclQualifier getObjCDeclQualifier() const
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Base class for declarations which introduce a typedef-name.
Represents a template argument.
void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
WarnExactTypedMethods - This routine issues a warning if method implementation declaration matches ex...
const ObjCProtocolList & getReferencedProtocols() const
instmeth_range instance_methods() const
TSCS getThreadStorageClassSpec() const
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
ObjCCategoryImplDecl * getImplementation() const
bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass, SmallVectorImpl< ObjCMethodDecl * > &Methods)
void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD)
DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which backs the property is n...
ObjCContainerKind getObjCContainerKind() const
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool CheckFunctionReturnType(QualType T, SourceLocation Loc)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ObjCIvarDecl * getPropertyIvarDecl() const
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
SourceLocation getLocStart() const LLVM_READONLY
void CheckConflictingOverridingMethod(ObjCMethodDecl *Method, ObjCMethodDecl *Overridden, bool IsProtocolMethodDecl)
bool ObjCIsSecondaryInit
True when this is an initializer method not marked as a designated initializer within a class that ha...
Decl * ActOnStartClassInterface(Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, AttributeList *AttrList)
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.
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.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool hasDefinition() const
Determine whether this protocol has a definition.
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
Selector getSelector() const
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
detail::InMemoryDirectory::const_iterator E
static bool matchTypes(ASTContext &Context, Sema::MethodMatchStrategy strategy, QualType leftQT, QualType rightQT)
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
IdentifierResolver IdResolver
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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)
DeclClass * getCorrectionDeclAs() const
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).
Represents a pointer to an Objective C object.
bool hasMoreThanOneDecl() const
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.
bool isObjCObjectType() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
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).
SourceManager & getSourceManager() const
void setNext(ObjCMethodList *L)
const T * getAs() const
Member-template getAs<specific type>'.
ExternalSemaSource * getExternalSource() const
static bool isMethodContextSameForKindofLookup(ObjCMethodDecl *Method, ObjCMethodDecl *MethodInList)
Decl::Kind getDeclKind() const
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
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
static const TST TST_typename
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 ...
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...
const ObjCProtocolList & getReferencedProtocols() const
Wraps an ObjCPointerType with source location information.
ObjCImplementationDecl * getImplementation() const
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...
bool isInlineSpecified() const
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)
IdentifierInfo * getIdentifier() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
ObjCInterfaceDecl * getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
Reading or writing from this object requires a barrier call.
classmeth_range class_methods() const
No particular method family.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node...
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Captures information about "declaration specifiers".
SourceLocation getIdentifierLoc() const
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...
bool isObjCObjectPointerType() const
void SetRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, const ObjCMethodDecl *PrevMethod, MethodMatchStrategy strategy=MMS_strict)
MatchTwoMethodDeclarations - Checks if two methods' type match and returns true, or false...
ObjCIvarDecl - Represents an ObjC instance variable.
bool CheckObjCDeclScope(Decl *D)
Checks that the Objective-C declaration is declared in the global scope.
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...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
Decl * ActOnMethodDeclaration(Scope *S, SourceLocation BeginLoc, SourceLocation EndLoc, tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, ArrayRef< SourceLocation > SelectorLocs, Selector Sel, ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
a linked list of methods with the same selector name but different signatures.
ObjCInterfaceDecl * getSuperClass() const
std::pair< ObjCMethodList, ObjCMethodList > GlobalMethods
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl * > &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
bool isSet() const
Deprecated.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
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.
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static SourceRange getTypeRange(TypeSourceInfo *TSI)
NamedDecl - This represents a decl with a name.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
bool isInvalidType() const
SourceRange getSourceRange() const
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)
ObjCMethodList * getNext() const
bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT, bool IsParam) const
Decl * ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CatName, SourceLocation CatLoc)
ActOnStartCategoryImplementation - Perform semantic checks on the category implementation declaration...
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
TypeSourceInfo * getTypeSourceInfo() const
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
static void diagnoseUseOfProtocols(Sema &TheSema, ObjCContainerDecl *CD, ObjCProtocolDecl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs)
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
void SetRangeEnd(SourceLocation Loc)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
void setType(QualType newType)
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
ParsedAttributes - A collection of parsed attributes.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
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.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
visible_extensions_range visible_extensions() const
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...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
ObjCCompatibleAliasDecl - Represents alias of a class.
Helper class that creates diagnostics with optional template instantiation stacks.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
AttributeList - Represents a syntactic attribute.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
const ObjCProtocolList & getReferencedProtocols() const
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
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 ObjCInterfaceDecl * getSuperClass() const