28 #include "llvm/ADT/DenseMap.h"
29 #include "llvm/ADT/DenseSet.h"
31 using namespace clang;
61 assert(resultClass &&
"unexpected object type!");
66 if (receiverTypeIfCall.
isNull() &&
76 if (receiverTypeIfCall.
isNull())
83 if (!receiverClass)
return false;
86 assert(receiverClass &&
"method not associated with a class!");
102 UnavailableAttr::IR_ARCInitReturnsUnrelated, loc));
107 Diag(loc, diag::err_arc_init_method_unrelated_result_type);
129 CurrentClass = Cat->getClassInterface();
130 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(DC))
131 CurrentClass = Impl->getClassInterface();
133 = dyn_cast<ObjCCategoryImplDecl>(DC))
134 CurrentClass = CatImpl->getClassInterface();
139 diag::warn_related_result_type_compatibility_class)
145 diag::warn_related_result_type_compatibility_protocol)
152 diag::note_related_result_type_family)
157 diag::note_related_result_type_overridden);
160 if ((NewMethod->
hasAttr<NSReturnsRetainedAttr>() !=
161 Overridden->
hasAttr<NSReturnsRetainedAttr>())) {
163 diag::err_nsreturns_retained_attribute_mismatch) << 1;
167 if ((NewMethod->
hasAttr<NSReturnsNotRetainedAttr>() !=
168 Overridden->
hasAttr<NSReturnsNotRetainedAttr>())) {
170 diag::err_nsreturns_retained_attribute_mismatch) << 0;
178 ni != ne && oi != oe; ++ni, ++oi) {
181 if (newDecl->
hasAttr<NSConsumedAttr>() !=
182 oldDecl->
hasAttr<NSConsumedAttr>()) {
184 diag::err_nsconsumed_attribute_mismatch);
232 if (method->
hasAttr<NSReturnsRetainedAttr>())
240 if (method->
hasAttr<NSReturnsRetainedAttr>() ||
241 method->
hasAttr<NSReturnsNotRetainedAttr>() ||
242 method->
hasAttr<NSReturnsAutoreleasedAttr>())
255 bool IsCategory =
false;
258 if (isa<ObjCMethodDecl>(ND)) {
262 S.
Diag(ImplLoc, diag::warn_unavailable_def);
267 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND)) {
268 if (!CD->getClassInterface()->isDeprecated())
270 ND = CD->getClassInterface();
275 S.
Diag(ImplLoc, diag::warn_deprecated_def)
276 << (isa<ObjCMethodDecl>(ND)
278 : isa<ObjCCategoryDecl>(ND) || IsCategory ? 2
280 if (isa<ObjCMethodDecl>(ND))
285 << (isa<ObjCCategoryDecl>(ND) ?
"category" :
"class");
350 if (!Param->isInvalidDecl() &&
353 Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
356 if (Param->getIdentifier())
399 ImplDeclOfMethodDecl = OID->getImplementation();
400 else if (
ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContDeclOfMethodDecl)) {
401 if (CD->IsClassExtension()) {
403 ImplDeclOfMethodDecl = OID->getImplementation();
405 ImplDeclOfMethodDecl = CD->getImplementation();
409 if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
417 IC->getSuperClass() !=
nullptr;
418 }
else if (IC->hasDesignatedInitializers()) {
444 (SuperMethod && SuperMethod->
hasAttr<ObjCRequiresSuperAttr>());
457 ObjCInterfaceValidatorCCC() : CurrentIDecl(nullptr) {}
459 : CurrentIDecl(IDecl) {}
461 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
475 unsigned NumProtoRefs,
480 for (
unsigned i = 0; i < NumProtoRefs; ++i) {
508 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(IDecl),
511 << SuperName << ClassName);
517 Diag(SuperLoc, diag::err_recursive_superclass)
518 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
522 dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
526 if (SuperClassDecl) {
531 if (PrevDecl && !SuperClassDecl) {
535 dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
536 QualType T = TDecl->getUnderlyingType();
556 if (!SuperClassDecl) {
557 Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
562 if (!dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
564 Diag(SuperLoc, diag::err_undef_superclass)
565 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
568 diag::err_forward_superclass,
571 SourceRange(AtInterfaceLoc, ClassLoc))) {
572 SuperClassDecl =
nullptr;
577 if (SuperClassType.isNull()) {
578 assert(!SuperClassDecl &&
"Failed to set SuperClassType?");
584 if (!SuperTypeArgs.empty()) {
592 SuperTypeArgsRange.
getEnd(),
604 if (!SuperClassTInfo) {
624 if (parsedTypeBound) {
635 diag::err_objc_type_param_bound_missing_pointer)
636 << typeBound << paramName
655 diag::err_objc_type_param_bound_nonobject)
656 << typeBound << paramName;
659 typeBoundInfo =
nullptr;
668 bool diagnosed =
false;
672 rangeToRemove = attr.getLocalSourceRange();
673 if (attr.getTypePtr()->getImmediateNullability()) {
674 Diag(attr.getLocStart(),
675 diag::err_objc_type_param_bound_explicit_nullability)
676 << paramName << typeBound
686 diag::err_objc_type_param_bound_qualified)
696 if (!quals.
empty()) {
706 if (!typeBoundInfo) {
713 index, paramLoc, paramName, colonLoc,
724 reinterpret_cast<ObjCTypeParamDecl * const *>(typeParamsIn.data()),
725 typeParamsIn.size());
731 llvm::SmallDenseMap<IdentifierInfo *, ObjCTypeParamDecl *> knownParams;
732 for (
auto typeParam : typeParams) {
733 auto known = knownParams.find(typeParam->getIdentifier());
734 if (known != knownParams.end()) {
735 Diag(typeParam->getLocation(), diag::err_objc_type_param_redecl)
736 << typeParam->getIdentifier()
739 typeParam->setInvalidDecl();
741 knownParams.insert(std::make_pair(typeParam->getIdentifier(), typeParam));
753 for (
auto typeParam : *typeParamList) {
754 if (!typeParam->isInvalidDecl()) {
780 if (prevTypeParams->
size() != newTypeParams->
size()) {
782 if (newTypeParams->
size() > prevTypeParams->
size()) {
788 S.
Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
789 <<
static_cast<unsigned>(newContext)
790 << (newTypeParams->
size() > prevTypeParams->
size())
791 << prevTypeParams->
size()
792 << newTypeParams->
size();
798 for (
unsigned i = 0, n = prevTypeParams->
size(); i != n; ++i) {
805 newContext != TypeParamListContext::Definition) {
824 auto diag = S.
Diag(diagLoc,
825 diag::err_objc_type_param_variance_conflict)
826 <<
static_cast<unsigned>(newTypeParam->
getVariance())
828 <<
static_cast<unsigned>(prevTypeParam->
getVariance())
837 StringRef newVarianceStr
844 (newVarianceStr +
" ").str());
871 S.
Diag(newBoundRange.
getBegin(), diag::err_objc_type_param_bound_conflict)
896 if (newContext == TypeParamListContext::ForwardDeclaration ||
897 newContext == TypeParamListContext::Definition) {
905 diag::err_objc_type_param_bound_missing)
908 << (newContext == TypeParamListContext::ForwardDeclaration)
930 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
933 assert(ClassName &&
"Missing class identifier");
939 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
940 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
971 TypeParamListContext::Definition)) {
972 typeParamList =
nullptr;
975 Diag(ClassLoc, diag::err_objc_parameterized_forward_class_first)
977 Diag(prevTypeParamList->getLAngleLoc(), diag::note_previous_decl)
982 for (
auto typeParam : *prevTypeParamList) {
983 clonedTypeParams.push_back(
987 typeParam->getVariance(),
989 typeParam->getIndex(),
991 typeParam->getIdentifier(),
1006 typeParamList, PrevIDecl, ClassLoc);
1010 Diag(AtInterfaceLoc, diag::err_duplicate_class_def)
1012 Diag(Def->getLocation(), diag::note_previous_definition);
1032 ClassName, ClassLoc,
1033 SuperName, SuperLoc, SuperTypeArgs,
1034 SuperTypeArgsRange);
1042 NumProtoRefs, ProtoLocs);
1066 if (
const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) {
1067 QualType T = TDecl->getUnderlyingType();
1070 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end());
1075 ProtocolLocs.append(OPT->getNumProtocols(), SuperLoc);
1091 Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
1099 dyn_cast_or_null<TypedefNameDecl>(CDeclU)) {
1100 QualType T = TDecl->getUnderlyingType();
1103 ClassName = IDecl->getIdentifier();
1111 Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
1134 E = PList.
end();
I !=
E; ++
I) {
1137 if (PDecl->getIdentifier() == PName) {
1138 Diag(Ploc, diag::err_protocol_has_circular_dependency);
1139 Diag(PrevLoc, diag::note_previous_definition);
1143 if (!PDecl->hasDefinition())
1147 PDecl->getLocation(), PDecl->getReferencedProtocols()))
1158 Decl *
const *ProtoRefs,
1159 unsigned NumProtoRefs,
1165 assert(ProtocolName &&
"Missing protocol identifier");
1171 Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName;
1172 Diag(Def->getLocation(), diag::note_previous_definition);
1179 ProtocolLoc, AtProtoInterfaceLoc,
1181 PDecl->startDefinition();
1189 ProtocolName, ProtocolLoc, PrevDecl->
getLocation(), PList);
1194 ProtocolLoc, AtProtoInterfaceLoc,
1209 if (!err && NumProtoRefs ) {
1212 NumProtoRefs, ProtoLocs);
1224 UndefinedProtocol = PDecl;
1230 UndefinedProtocol = PI;
1257 Diag(Pair.second, diag::err_undeclared_protocol) << Pair.first;
1266 if (!ForObjCContainer) {
1275 if (WarnOnDeclarations &&
1277 Diag(Pair.second, diag::warn_undef_protocolref) << Pair.first;
1278 Diag(UndefinedProtocol->
getLocation(), diag::note_protocol_decl_undefined)
1279 << UndefinedProtocol;
1281 Protocols.push_back(PDecl);
1292 ObjCTypeArgOrProtocolValidatorCCC(
ASTContext &context,
1294 :
Context(context), LookupKind(lookupKind) { }
1296 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
1316 if (
type->isObjCObjectPointerType() ||
1317 type->isBlockPointerType() ||
1318 type->isDependentType() ||
1319 type->isObjCObjectType())
1342 bool SelectProtocolFirst) {
1343 Diag(TypeArgLoc, diag::err_objc_type_args_and_protocols)
1344 << SelectProtocolFirst << TypeArgId << ProtocolId
1361 bool warnOnIncompleteProtocols) {
1364 unsigned numProtocolsResolved = 0;
1365 auto resolvedAsProtocols = [&] {
1366 assert(numProtocolsResolved == identifiers.size() &&
"Unresolved protocols");
1373 bool allAreTypeNames =
false;
1377 baseClass = objcObjectType->getInterface();
1379 if (
auto typeParams = baseClass->getTypeParamList()) {
1380 if (typeParams->size() == numProtocolsResolved) {
1382 allAreTypeNames =
true;
1389 for (
unsigned i = 0, n = protocols.size(); i != n; ++i) {
1394 if (!warnOnIncompleteProtocols) {
1406 if (warnOnIncompleteProtocols &&
1408 Diag(identifierLocs[i], diag::warn_undef_protocolref)
1417 if (allAreTypeNames) {
1420 if (isa<ObjCInterfaceDecl>(
decl)) {
1422 firstClassNameLoc = identifierLocs[i];
1423 }
else if (!isa<TypeDecl>(
decl)) {
1425 allAreTypeNames =
false;
1428 allAreTypeNames =
false;
1437 if (allAreTypeNames && firstClassNameLoc.
isValid()) {
1438 llvm::SmallPtrSet<ObjCProtocolDecl*, 8> knownProtocols;
1440 bool allProtocolsDeclared =
true;
1441 for (
auto proto : protocols) {
1442 if (knownProtocols.count(static_cast<ObjCProtocolDecl *>(proto)) == 0) {
1443 allProtocolsDeclared =
false;
1448 if (allProtocolsDeclared) {
1449 Diag(firstClassNameLoc, diag::warn_objc_redundant_qualified_class_type)
1450 << baseClass->getDeclName() <<
SourceRange(lAngleLoc, rAngleLoc)
1456 protocolLAngleLoc = lAngleLoc;
1457 protocolRAngleLoc = rAngleLoc;
1458 assert(protocols.size() == identifierLocs.size());
1462 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1464 protocols.push_back(proto);
1466 ++numProtocolsResolved;
1470 if (numProtocolsResolved == identifiers.size())
1471 return resolvedAsProtocols();
1477 typedef llvm::PointerUnion<TypeDecl *, ObjCInterfaceDecl *> TypeOrClassDecl;
1479 unsigned numTypeDeclsResolved = 0;
1480 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1484 typeDecls.push_back(TypeOrClassDecl());
1488 if (
auto typeDecl = dyn_cast<TypeDecl>(decl)) {
1489 typeDecls.push_back(typeDecl);
1490 ++numTypeDeclsResolved;
1494 if (
auto objcClass = dyn_cast<ObjCInterfaceDecl>(decl)) {
1495 typeDecls.push_back(objcClass);
1496 ++numTypeDeclsResolved;
1500 typeDecls.push_back(TypeOrClassDecl());
1507 auto resolveTypeReference = [&](TypeOrClassDecl typeDecl,
SourceLocation loc)
1511 const char* prevSpec;
1514 if (
auto *actualTypeDecl = typeDecl.dyn_cast<
TypeDecl *>())
1544 Diag(loc, diag::err_objc_type_arg_missing_star)
1555 auto resolvedAsTypeDecls = [&] {
1559 assert(numTypeDeclsResolved == identifiers.size() &&
"Unresolved type decl");
1561 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1563 TypeResult type = resolveTypeReference(typeDecls[i], identifierLocs[i]);
1569 typeArgs.push_back(type.
get());
1572 typeArgsLAngleLoc = lAngleLoc;
1573 typeArgsRAngleLoc = rAngleLoc;
1578 if (numTypeDeclsResolved == identifiers.size())
1579 return resolvedAsTypeDecls();
1585 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1588 if (protocols[i] || typeDecls[i]) {
1594 if (protocols[i] && typeDecls[i])
1617 identifiers[i], identifierLocs[i],
1618 protocols[i] !=
nullptr);
1629 llvm::make_unique<ObjCTypeArgOrProtocolValidatorCCC>(
Context,
1636 PDiag(diag::err_undeclared_protocol_suggest)
1639 protocols[i] = proto;
1640 ++numProtocolsResolved;
1647 PDiag(diag::err_unknown_typename_suggest)
1650 typeDecls[i] = typeDecl;
1651 ++numTypeDeclsResolved;
1658 PDiag(diag::err_unknown_type_or_class_name_suggest)
1659 << identifiers[i] <<
true);
1661 typeDecls[i] = objcClass;
1662 ++numTypeDeclsResolved;
1668 Diag(identifierLocs[i],
1669 (lookupKind ==
LookupAnyName ? diag::err_objc_type_arg_missing
1671 : diag::err_unknown_typename))
1680 if (numProtocolsResolved == identifiers.size())
1681 return resolvedAsProtocols();
1684 assert(numTypeDeclsResolved == identifiers.size() &&
"Not all types?");
1685 return resolvedAsTypeDecls();
1696 llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
1697 for (
auto *MD : ID->
methods())
1698 MethodMap[MD->getSelector()] = MD;
1700 if (MethodMap.empty())
1702 for (
const auto *Method : CAT->
methods()) {
1703 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
1707 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
1708 << Method->getDeclName();
1726 IdentPair.second, AtProtocolLoc,
1739 DeclsInGroup.push_back(PDecl);
1751 Decl *
const *ProtoRefs,
1752 unsigned NumProtoRefs,
1763 diag::err_category_forward_interface,
1764 CategoryName ==
nullptr)) {
1769 ClassLoc, CategoryLoc, CategoryName,
1770 IDecl, typeParamList);
1775 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1780 Diag(ClassLoc, diag::err_class_extension_after_impl) << ClassName;
1782 diag::note_implementation_declared);
1790 Diag(CategoryLoc, diag::warn_dup_category_def)
1791 << ClassName << CategoryName;
1792 Diag(
Previous->getLocation(), diag::note_previous_definition);
1797 if (typeParamList) {
1802 : TypeParamListContext::Extension))
1803 typeParamList =
nullptr;
1806 diag::err_objc_parameterized_category_nonclass)
1807 << (CategoryName !=
nullptr)
1811 typeParamList =
nullptr;
1816 ClassLoc, CategoryLoc, CategoryName, IDecl,
1823 NumProtoRefs, ProtoLocs);
1864 ClassLoc, AtCatImplLoc, CatLoc);
1867 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1870 diag::err_undef_interface)) {
1879 if (IDecl && IDecl->
hasAttr<ObjCRuntimeVisibleAttr>()) {
1880 Diag(ClassLoc, diag::err_objc_runtime_visible_category)
1887 Diag(ClassLoc, diag::err_dup_implementation_category) << ClassName
1890 diag::note_previous_definition);
1915 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1916 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
1918 }
else if ((IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl))) {
1922 diag::warn_undef_interface);
1928 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(),
CTK_NonError);
1934 PDiag(diag::warn_undef_interface_suggest) << ClassName,
1937 Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
1943 if (SuperClassname) {
1947 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1948 Diag(SuperClassLoc, diag::err_redefinition_different_kind)
1952 SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
1956 Diag(SuperClassLoc, diag::err_undef_superclass)
1957 << SuperClassname << ClassName;
1961 Diag(SuperClassLoc, diag::err_conflicting_super_class)
2000 ClassLoc, AtClassImplLoc, SuperClassLoc);
2008 Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
2010 diag::note_previous_definition);
2024 Diag(ClassLoc, diag::err_objc_runtime_visible_subclass)
2035 DeclsInGroup.reserve(Decls.size() + 1);
2037 for (
unsigned i = 0, e = Decls.size(); i != e; ++i) {
2038 Decl *Dcl = Decls[i];
2043 DeclsInGroup.push_back(Dcl);
2046 DeclsInGroup.push_back(ObjCImpDecl);
2054 assert(ImpDecl &&
"missing implementation decl");
2064 for (
unsigned i = 0, e = numIvars; i != e; ++i) {
2076 assert(ivars &&
"missing @implementation ivars");
2080 for (
unsigned i = 0; i < numIvars; i++) {
2085 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2093 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
2110 for (; numIvars > 0 && IVI != IVE; ++IVI) {
2113 assert (ImplIvar &&
"missing implementation ivar");
2114 assert (ClsIvar &&
"missing class ivar");
2126 diag::err_conflicting_ivar_bitwidth) << ImplIvar->
getIdentifier();
2128 diag::note_previous_definition);
2140 Diag(ivars[j]->getLocation(), diag::err_inconsistent_ivar_count);
2141 else if (IVI != IVE)
2142 Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
2147 bool &IncompleteImpl,
2177 S.
Diag(MethodLoc, diag::note_method_declared_at) << method;
2255 (y & ~
Decl::OBJC_TQ_CSNullability);
2261 bool IsProtocolMethodDecl,
2262 bool IsOverridingMode,
2264 if (IsProtocolMethodDecl &&
2270 ? diag::warn_conflicting_overriding_ret_type_modifiers
2271 : diag::warn_conflicting_ret_type_modifiers))
2280 if (Warn && IsOverridingMode &&
2285 auto nullabilityMethodImpl =
2287 auto nullabilityMethodDecl =
2290 diag::warn_conflicting_nullability_attr_overriding_ret_types)
2292 nullabilityMethodImpl,
2296 nullabilityMethodDecl,
2309 IsOverridingMode ? diag::warn_conflicting_overriding_ret_types
2310 : diag::warn_conflicting_ret_types;
2326 IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types
2327 : diag::warn_non_covariant_ret_types;
2336 ? diag::note_previous_declaration
2337 : diag::note_previous_definition)
2347 bool IsProtocolMethodDecl,
2348 bool IsOverridingMode,
2350 if (IsProtocolMethodDecl &&
2354 if (IsOverridingMode)
2356 diag::warn_conflicting_overriding_param_modifiers)
2360 diag::warn_conflicting_param_modifiers)
2372 if (Warn && IsOverridingMode &&
2376 diag::warn_conflicting_nullability_attr_overriding_param_types)
2393 IsOverridingMode ? diag::warn_conflicting_overriding_param_types
2394 : diag::warn_conflicting_param_types;
2410 IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types
2411 : diag::warn_non_contravariant_param_types;
2417 << MethodImpl->
getDeclName() << IfaceTy << ImplTy;
2419 (IsOverridingMode ? diag::note_previous_declaration
2420 : diag::note_previous_definition))
2431 if (implFamily == declFamily)
return false;
2443 unsigned errorID = diag::err_arc_lost_method_convention;
2444 unsigned noteID = diag::note_arc_lost_method_convention;
2447 family = implFamily;
2448 errorID = diag::err_arc_gained_method_convention;
2449 noteID = diag::note_arc_gained_method_convention;
2453 enum FamilySelector {
2454 F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new
2456 FamilySelector familySelector = FamilySelector();
2459 case OMF_None: llvm_unreachable(
"logic error, no method convention");
2473 case OMF_init: familySelector = F_init;
break;
2474 case OMF_alloc: familySelector = F_alloc;
break;
2475 case OMF_copy: familySelector = F_copy;
break;
2477 case OMF_new: familySelector = F_new;
break;
2480 enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn };
2481 ReasonSelector reasonSelector;
2486 reasonSelector = R_UnrelatedReturn;
2488 reasonSelector = R_NonObjectReturn;
2491 S.
Diag(impl->
getLocation(), errorID) <<
int(familySelector) << int(reasonSelector);
2492 S.
Diag(decl->
getLocation(), noteID) <<
int(familySelector) << int(reasonSelector);
2499 bool IsProtocolMethodDecl) {
2505 IsProtocolMethodDecl,
false,
2511 IM != EM && IF != EF; ++IM, ++IF) {
2513 IsProtocolMethodDecl,
false,
true);
2518 diag::warn_conflicting_variadic);
2525 bool IsProtocolMethodDecl) {
2528 IsProtocolMethodDecl,
true,
2534 IM != EM && IF != EF; ++IM, ++IF) {
2536 IsProtocolMethodDecl,
true,
true);
2541 diag::warn_conflicting_overriding_variadic);
2550 bool IsProtocolMethodDecl) {
2558 if (MethodDecl->
hasAttr<UnavailableAttr>() ||
2559 MethodDecl->
hasAttr<DeprecatedAttr>())
2563 IsProtocolMethodDecl,
false,
false);
2568 IM != EM && IF != EF; ++IM, ++IF) {
2571 IsProtocolMethodDecl,
false,
false);
2583 diag::warn_category_method_impl_match);
2600 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>())
2602 for (
const auto *PI : PDecl->
protocols())
2625 bool& IncompleteImpl,
2633 assert (IDecl &&
"CheckProtocolMethodDefs - IDecl is null");
2649 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>()) {
2650 if (!ProtocolsExplictImpl) {
2655 ProtocolsExplictImpl->end())
2673 if (InsMap.count(fISelector))
2693 !method->isPropertyAccessor() &&
2694 !InsMap.count(method->getSelector()) &&
2710 IDecl->lookupMethod(method->getSelector(),
2714 if (C || MethodInClass->isPropertyAccessor())
2716 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2726 !ClsMap.count(method->getSelector()) &&
2733 if (C && IDecl->lookupMethod(method->getSelector(),
2739 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2748 CDecl, ProtocolsExplictImpl);
2760 bool &IncompleteImpl,
2761 bool ImmediateClass,
2762 bool WarnCategoryMethodImpl) {
2766 if (!InsMapSeen.insert(
I->getSelector()).second)
2768 if (!
I->isPropertyAccessor() &&
2769 !InsMap.count(
I->getSelector())) {
2772 diag::warn_undef_method_impl);
2778 "Expected to find the method through lookup as well");
2780 if (ImpMethodDecl) {
2781 if (!WarnCategoryMethodImpl)
2783 isa<ObjCProtocolDecl>(CDecl));
2784 else if (!
I->isPropertyAccessor())
2793 if (!ClsMapSeen.insert(
I->getSelector()).second)
2795 if (!
I->isPropertyAccessor() &&
2796 !ClsMap.count(
I->getSelector())) {
2799 diag::warn_undef_method_impl);
2804 "Expected to find the method through lookup as well");
2806 if (ImpMethodDecl) {
2807 if (!WarnCategoryMethodImpl)
2809 isa<ObjCProtocolDecl>(CDecl));
2810 else if (!
I->isPropertyAccessor())
2819 for (
auto *PI : PD->protocols())
2821 IMPDecl, PI, IncompleteImpl,
false,
2822 WarnCategoryMethodImpl);
2829 if (!WarnCategoryMethodImpl) {
2830 for (
auto *Cat :
I->visible_categories())
2832 IMPDecl, Cat, IncompleteImpl,
2833 ImmediateClass && Cat->IsClassExtension(),
2834 WarnCategoryMethodImpl);
2837 for (
auto *Ext :
I->visible_extensions())
2839 IMPDecl, Ext, IncompleteImpl,
false,
2840 WarnCategoryMethodImpl);
2844 for (
auto *PI :
I->all_referenced_protocols())
2846 IMPDecl, PI, IncompleteImpl,
false,
2847 WarnCategoryMethodImpl);
2851 if (!WarnCategoryMethodImpl &&
I->getSuperClass())
2854 I->getSuperClass(), IncompleteImpl,
false);
2885 if (SuperIDecl && SuperIDecl->
lookupMethod(Sel,
false))
2889 if (InsMap.empty() && ClsMap.empty())
2893 bool IncompleteImpl =
false;
2896 IncompleteImpl,
false,
2902 bool IncompleteImpl) {
2907 InsMap.insert(
I->getSelector());
2915 const auto *
P = PImpl->getPropertyDecl();
2918 InsMap.insert(
P->getGetterName());
2919 if (!
P->getSetterName().isNull())
2920 InsMap.insert(
P->getSetterName());
2927 bool SynthesizeProperties =
LangOpts.ObjCDefaultSynthProperties &&
2929 !IDecl->isObjCRequiresPropertyDefs();
2938 ClsMap.insert(
I->getSelector());
2945 IncompleteImpl,
true);
2950 dyn_cast<ObjCCategoryImplDecl>(IMPDecl))
2961 for (
auto *PI :
I->all_referenced_protocols())
2963 InsMap, ClsMap,
I, ExplicitImplProtocols);
2967 if (!C->IsClassExtension()) {
2968 for (
auto *
P : C->protocols())
2970 IncompleteImpl, InsMap, ClsMap, CDecl,
2971 ExplicitImplProtocols);
2976 llvm_unreachable(
"invalid ObjCContainerDecl type.");
2986 for (
unsigned i = 0; i != NumElts; ++i) {
2991 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
3001 Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
3009 Diag(AtClassLoc, diag::warn_forward_class_redefinition)
3019 = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
3041 if (PrevIDecl && TypeParams) {
3045 *
this, PrevTypeParams, TypeParams,
3046 TypeParamListContext::ForwardDeclaration)) {
3047 TypeParams =
nullptr;
3051 Diag(IdentLocs[i], diag::err_objc_parameterized_forward_class)
3054 Diag(Def->getLocation(), diag::note_defined_here)
3057 TypeParams =
nullptr;
3063 ClassName, TypeParams, PrevIDecl,
3069 DeclsInGroup.push_back(IDecl);
3077 const Type *left,
const Type *right);
3086 if (left == right)
return true;
3109 if (isa<VectorType>(left))
return isa<VectorType>(right);
3110 if (isa<VectorType>(right))
return false;
3133 return (leftSK == rightSK);
3139 assert(lt && rt && lt != rt);
3141 if (!isa<RecordType>(lt) || !isa<RecordType>(rt))
return false;
3142 RecordDecl *left = cast<RecordType>(lt)->getDecl();
3143 RecordDecl *right = cast<RecordType>(rt)->getDecl();
3149 if ((isa<CXXRecordDecl>(left) && !cast<CXXRecordDecl>(left)->isPOD()) ||
3150 (isa<CXXRecordDecl>(right) && !cast<CXXRecordDecl>(right)->isPOD()))
3165 for (; li != le && ri != re; ++li, ++ri) {
3166 if (!
matchTypes(Context, strategy, li->getType(), ri->getType()))
3169 return (li == le && ri == re);
3187 (left->
hasAttr<NSReturnsRetainedAttr>()
3188 != right->
hasAttr<NSReturnsRetainedAttr>() ||
3189 left->
hasAttr<NSConsumesSelfAttr>()
3190 != right->
hasAttr<NSConsumesSelfAttr>()))
3197 for (; li != le && ri != re; ++li, ++ri) {
3198 assert(ri != right->
param_end() &&
"Param mismatch");
3205 lparm->hasAttr<NSConsumedAttr>() != rparm->hasAttr<NSConsumedAttr>())
3214 auto *MethodInListProtocol =
3218 if ((MethodProtocol && !MethodInListProtocol) ||
3219 (!MethodProtocol && MethodInListProtocol))
3222 if (MethodProtocol && MethodInListProtocol)
3228 return MethodInterface == MethodInListInterface;
3237 if (!CD->IsClassExtension() && List->
getBits() < 2)
3251 for (; List; Previous = List, List = List->
getNext()) {
3268 if (!SameDeclaration ||
3274 List->setHasMoreThanOneDecl(
true);
3280 ListWithSameDeclaration = List;
3283 !ListWithSameDeclaration &&
3285 ListWithSameDeclaration = List;
3299 List->setHasMoreThanOneDecl(
true);
3306 List->setMethod(Method);
3312 List->setMethod(Method);
3323 if (ListWithSameDeclaration) {
3326 ListWithSameDeclaration->
setMethod(Method);
3327 ListWithSameDeclaration->
setNext(List);
3337 assert(ExternalSource &&
"We need an external AST source");
3342 if (!ExternalSource)
3347 void Sema::AddMethodToGlobalPool(
ObjCMethodDecl *Method,
bool impl,
3363 ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
3397 assert(BoundInterface &&
"unexpected object type!");
3402 if (MethodProtocol) {
3412 return MethodInterface == BoundInterface ||
3413 MethodInterface->isSuperClassOf(BoundInterface) ||
3414 BoundInterface->isSuperClassOf(MethodInterface);
3416 llvm_unreachable(
"unknow method context");
3423 bool InstanceFirst,
bool CheckTheOther,
3428 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3436 if (M->getMethod() && !M->getMethod()->isHidden()) {
3438 Methods.push_back(M->getMethod());
3442 if (!Methods.empty())
3443 return Methods.size() > 1;
3452 if (M->getMethod() && !M->getMethod()->isHidden()) {
3454 Methods.push_back(M->getMethod());
3457 return Methods.size() > 1;
3465 FilteredMethods.push_back(BestMethod);
3467 for (
auto *M : Methods)
3468 if (M != BestMethod && !M->
hasAttr<UnavailableAttr>())
3469 FilteredMethods.push_back(M);
3471 if (FilteredMethods.size() > 1)
3475 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3486 bool receiverIdOrClass,
3491 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3496 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
3499 if (M->getMethod() && !M->getMethod()->isHidden())
3500 return M->getMethod();
3507 bool receiverIdOrClass) {
3509 bool issueDiagnostic =
false, issueError =
false;
3513 bool strictSelectorMatch =
3514 receiverIdOrClass &&
3516 if (strictSelectorMatch) {
3517 for (
unsigned I = 1, N = Methods.size();
I != N; ++
I) {
3519 issueDiagnostic =
true;
3528 if (!strictSelectorMatch ||
3529 (issueDiagnostic &&
getLangOpts().ObjCAutoRefCount))
3530 for (
unsigned I = 1, N = Methods.size();
I != N; ++
I) {
3534 issueDiagnostic =
true;
3541 if (issueDiagnostic) {
3543 Diag(R.
getBegin(), diag::err_arc_multiple_method_decl) << Sel << R;
3544 else if (strictSelectorMatch)
3545 Diag(R.
getBegin(), diag::warn_strict_multiple_method_decl) << Sel << R;
3547 Diag(R.
getBegin(), diag::warn_multiple_method_decl) << Sel << R;
3549 Diag(Methods[0]->getLocStart(),
3550 issueError ? diag::note_possibility : diag::note_using)
3551 << Methods[0]->getSourceRange();
3552 for (
unsigned I = 1, N = Methods.size();
I != N; ++
I) {
3553 Diag(Methods[
I]->getLocStart(), diag::note_also_found)
3554 << Methods[
I]->getSourceRange();
3560 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3566 Method = Method->getNext())
3567 if (Method->getMethod() &&
3570 return Method->getMethod();
3573 Method = Method->getNext())
3574 if (Method->getMethod() &&
3577 return Method->getMethod();
3589 unsigned MinPossibleEditDistance =
abs((
int)MethodName.size() - (int)Typo.size());
3590 if (MinPossibleEditDistance > 0 &&
3591 Typo.size() / MinPossibleEditDistance < 1)
3593 unsigned EditDistance = Typo.edit_distance(MethodName,
true, MaxEditDistance);
3594 if (EditDistance > MaxEditDistance)
3596 if (EditDistance == BestEditDistance)
3597 BestMethod.push_back(Method);
3598 else if (EditDistance < BestEditDistance) {
3600 BestMethod.push_back(Method);
3619 bool ObjectIsId =
true, ObjectIsClass =
true;
3621 ObjectIsId = ObjectIsClass =
false;
3626 ObjectType =
QualType(ObjCPtr->getInterfaceType(), 0);
3627 ObjectIsId = ObjectIsClass =
false;
3630 ObjectIsClass =
false;
3636 for (GlobalMethodPool::iterator b =
MethodPool.begin(),
3640 if (M->getMethod() &&
3641 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3642 (M->getMethod()->getSelector() != Sel)) {
3644 Methods.push_back(M->getMethod());
3645 else if (!ObjectIsClass &&
3648 Methods.push_back(M->getMethod());
3652 if (M->getMethod() &&
3653 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3654 (M->getMethod()->getSelector() != Sel)) {
3656 Methods.push_back(M->getMethod());
3657 else if (!ObjectIsId &&
3660 Methods.push_back(M->getMethod());
3665 for (
unsigned i = 0, e = Methods.size(); i < e; i++) {
3669 return (SelectedMethods.size() == 1) ? SelectedMethods[0] :
nullptr;
3679 for (
auto *Ivar : ID->
ivars()) {
3680 if (Ivar->isInvalidDecl())
3685 Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
3687 Ivar->setInvalidDecl();
3699 if (ivar->isInvalidDecl())
continue;
3702 S.
Diag(ivar->getLocation(), diag::err_arc_weak_disabled);
3704 S.
Diag(ivar->getLocation(), diag::err_arc_weak_no_runtime);
3712 case Decl::ObjCInterface:
3714 case Decl::ObjCProtocol:
3716 case Decl::ObjCCategory:
3717 if (cast<ObjCCategoryDecl>(
CurContext)->IsClassExtension())
3720 case Decl::ObjCImplementation:
3722 case Decl::ObjCCategoryImpl:
3736 assert(AtEnd.
isValid() &&
"Invalid location for '@end'");
3739 Decl *ClassDecl = cast<Decl>(OCD);
3741 bool isInterfaceDeclKind =
3742 isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl)
3743 || isa<ObjCProtocolDecl>(ClassDecl);
3744 bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
3747 llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap;
3748 llvm::DenseMap<Selector, const ObjCMethodDecl*> ClsMap;
3750 for (
unsigned i = 0, e = allMethods.size(); i != e; i++ ) {
3752 cast_or_null<ObjCMethodDecl>(allMethods[i]);
3754 if (!Method)
continue;
3760 if ((isInterfaceDeclKind && PrevMethod && !match)
3761 || (checkIdenticalMethods && match)) {
3784 if ((isInterfaceDeclKind && PrevMethod && !match)
3785 || (checkIdenticalMethods && match)) {
3804 if (isa<ObjCInterfaceDecl>(ClassDecl)) {
3811 if (C->IsClassExtension()) {
3817 if (CDecl->getIdentifier())
3821 for (
auto *
I : CDecl->properties())
3823 CDecl->setAtEndRange(AtEnd);
3826 IC->setAtEndRange(AtEnd);
3833 for (
const auto *Ext : IDecl->visible_extensions()) {
3834 for (
const auto *
Property : Ext->instance_properties()) {
3837 = IC->FindPropertyImplDecl(
Property->getIdentifier(),
3839 if (PIDecl->getPropertyImplementation()
3843 for (
const auto *Ext : IDecl->visible_extensions()) {
3845 = Ext->getInstanceMethod(
Property->getGetterName()))
3846 GetterMethod->setPropertyAccessor(
true);
3849 = Ext->getInstanceMethod(
Property->getSetterName()))
3850 SetterMethod->setPropertyAccessor(
true);
3858 if (IDecl->hasDesignatedInitializers())
3862 bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>();
3863 if (IDecl->getSuperClass() ==
nullptr) {
3866 if (!HasRootClassAttr) {
3869 Diag(DeclLoc, diag::warn_objc_root_class_missing)
3870 << IDecl->getIdentifier();
3877 if (NSObjectDecl && NSObjectDecl->getDefinition()) {
3878 Diag(SuperClassLoc, diag::note_objc_needs_superclass)
3881 Diag(SuperClassLoc, diag::note_objc_needs_superclass);
3884 }
else if (HasRootClassAttr) {
3886 Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass);
3894 if (IDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
3895 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
3896 Diag(IC->getLocation(), diag::err_restricted_superclass_mismatch);
3897 Diag(Super->getLocation(), diag::note_class_declared);
3902 while (IDecl->getSuperClass()) {
3904 IDecl = IDecl->getSuperClass();
3910 dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
3911 CatImplClass->setAtEndRange(AtEnd);
3917 = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier())) {
3921 }
else if (
const auto *IntfDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
3923 if (!IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
3924 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
3925 Diag(IntfDecl->getLocation(), diag::err_restricted_superclass_mismatch);
3926 Diag(Super->getLocation(), diag::note_class_declared);
3930 if (isInterfaceDeclKind) {
3932 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
3935 if (
VarDecl *VDecl = dyn_cast<VarDecl>(*
I)) {
3936 if (!VDecl->hasExternalStorage())
3937 Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass);
3943 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
3946 (*I)->setTopLevelDeclInObjCContainer();
3975 if (ResultObjectType->isObjCIdType() ||
3976 ResultObjectType->isObjCQualifiedIdType())
3981 = ResultObjectType->getInterfaceDecl()) {
3987 if (ResultClass->isSuperClassOf(CurrentClass))
4003 class OverrideSearch {
4007 llvm::SmallPtrSet<ObjCMethodDecl*, 4> Overridden;
4016 Sema::GlobalMethodPool::iterator it = S.
MethodPool.find(selector);
4036 searchFromContainer(container);
4038 searchFromContainer(Interface);
4040 searchFromContainer(container);
4044 typedef llvm::SmallPtrSetImpl<ObjCMethodDecl*>::iterator iterator;
4045 iterator begin()
const {
return Overridden.begin(); }
4046 iterator end()
const {
return Overridden.end(); }
4053 #define OBJCCONTAINER(type, base) \
4055 searchFrom(cast<type##Decl>(container)); \
4057 #define ABSTRACT_DECL(expansion)
4058 #define DECL(type, base) \
4060 #include "clang/AST/DeclNodes.inc"
4061 llvm_unreachable(
"not an ObjC container!");
4134 Overridden.insert(meth);
4144 searchFromContainer(container);
4153 OverrideSearch overrides(*
this, ObjCMethod);
4159 bool hasOverriddenMethodsInBaseOrProtocol =
false;
4160 for (OverrideSearch::iterator
4161 i = overrides.begin(), e = overrides.end(); i != e; ++i) {
4164 if (!hasOverriddenMethodsInBaseOrProtocol) {
4168 hasOverriddenMethodsInBaseOrProtocol =
true;
4178 GlobalMethodPool::iterator It =
4183 unsigned CategCount = List.
getBits();
4184 if (CategCount > 0) {
4187 if (CategCount > 1 ||
4189 OverrideSearch overrides(*
this, overridden);
4190 for (OverrideSearch::iterator
4191 OI= overrides.begin(), OE= overrides.end(); OI!=OE; ++OI) {
4195 hasOverriddenMethodsInBaseOrProtocol =
true;
4222 if (CurrentClass && overridden->
getDeclContext() != CurrentClass &&
4229 for (; ParamI !=
E && PrevI != PrevE; ++ParamI, ++PrevI) {
4230 assert(PrevI != overridden->
param_end() &&
"Param mismatch");
4236 Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
4245 ObjCMethod->
setOverriding(hasOverriddenMethodsInBaseOrProtocol);
4255 bool prevUsesCSKeyword) {
4261 if (nullability.hasValue() == prevNullability.hasValue()) {
4267 if (*nullability == *prevNullability)
4271 S.
Diag(loc, diag::err_nullability_conflicting)
4294 if (prevMethod->
hasAttr<ObjCRequiresSuperAttr>() &&
4295 !method->
hasAttr<ObjCRequiresSuperAttr>()) {
4298 ObjCRequiresSuperAttr::CreateImplicit(S.
Context,
4315 unsigned numPrevParams = prevMethod->
param_size();
4316 for (
unsigned i = 0, n =
std::min(numParams, numPrevParams); i != n; ++i) {
4336 llvm::Triple::x86 &&
4337 "x86-specific check invoked for a different target");
4341 if (
P->getType()->isVectorType()) {
4342 Loc =
P->getLocStart();
4347 if (Loc.isInvalid()) {
4359 if (Triple.getOS() == llvm::Triple::IOS)
4361 else if (Triple.isMacOSX())
4368 SemaRef.
Diag(Loc, diag::err_objc_method_unsupported_param_ret_type)
4371 << (Triple.isMacOSX() ?
"macOS 10.11" :
"iOS 9");
4386 bool isVariadic,
bool MethodDefinition) {
4389 Diag(MethodLoc, diag::err_missing_method_context);
4393 Decl *ClassDecl = cast<Decl>(OCD);
4396 bool HasRelatedResultType =
false;
4404 QualType bareResultType = resultDeclType;
4409 Diag(MethodLoc, diag::warn_missing_method_return_type)
4415 MethodType == tok::minus, isVariadic,
4420 HasRelatedResultType);
4424 for (
unsigned i = 0, e = Sel.
getNumArgs(); i != e; ++i) {
4428 if (!ArgInfo[i].
Type) {
4441 Diag(ArgInfo[i].NameLoc,
4442 (MethodDefinition ? diag::warn_method_param_redefinition
4443 : diag::warn_method_param_declaration))
4446 diag::note_previous_declaration);
4455 ArgInfo[i].NameLoc, ArgInfo[i].Name,
4467 if (Param->
hasAttr<BlocksAttr>()) {
4474 Params.push_back(Param);
4477 for (
unsigned i = 0, e = CNumArgs; i != e; ++i) {
4480 if (ArgType.isNull())
4487 Params.push_back(Param);
4500 if (
ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(ClassDecl)) {
4501 if (MethodType == tok::minus) {
4502 PrevMethod = ImpDecl->getInstanceMethod(Sel);
4503 ImpDecl->addInstanceMethod(ObjCMethod);
4505 PrevMethod = ImpDecl->getClassMethod(Sel);
4506 ImpDecl->addClassMethod(ObjCMethod);
4512 if (
auto *IMD = IDecl->lookupMethod(ObjCMethod->
getSelector(),
4517 if (isa<ObjCCategoryImplDecl>(ImpDecl) && IMD->isOverriding() &&
4525 cast<DeclContext>(ClassDecl)->addDecl(ObjCMethod);
4541 if (!CurrentClass) {
4543 CurrentClass = Cat->getClassInterface();
4544 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(ClassDecl))
4545 CurrentClass = Impl->getClassInterface();
4547 = dyn_cast<ObjCCategoryImplDecl>(ClassDecl))
4548 CurrentClass = CatImpl->getClassInterface();
4556 bool ARCError =
false;
4563 LangOpts.ObjCInferRelatedResultType) {
4564 bool InferRelatedResultType =
false;
4590 if (InferRelatedResultType &&
4595 if (MethodDefinition &&
4615 Diag(D->
getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
4629 Diag(DeclStart, diag::err_undef_interface) << ClassName;
4633 Diag(DeclStart, diag::err_atdef_nonfragile_interface);
4641 for (
unsigned i = 0; i < Ivars.size(); i++) {
4649 Decls.push_back(FD);
4654 D != Decls.end(); ++D) {
4658 else if (
RecordDecl *Record = dyn_cast<RecordDecl>(TagD))
4659 Record->addDecl(FD);
4674 Diag(IdLoc, diag::err_arg_with_address_space);
4686 Diag(IdLoc ,diag::err_catch_param_not_objc_type);
4689 Diag(IdLoc, diag::err_illegal_qualifiers_on_catch_parm);
4722 diag::err_invalid_thread)
4756 if (New->
hasAttr<BlocksAttr>())
4769 Ivars.push_back(Iv);
4775 if (ExternalSource) {
4778 for (
unsigned I = 0, N = Sels.size();
I != N; ++
I)
4789 Selector Sel = SelectorAndLocation.first;
4792 Diag(Loc, diag::warn_unimplemented_selector) << Sel;
4815 IV->getIdentifier());
4824 class UnusedBackingIvarChecker :
4831 bool InvokedSelfMethod;
4835 : S(S), Method(Method), IvarD(IvarD),
4836 AccessedIvar(
false), InvokedSelfMethod(
false) {
4842 AccessedIvar =
true;
4851 InvokedSelfMethod =
true;
4864 unsigned DIAG = diag::warn_unused_property_backing_ivar;
4874 UnusedBackingIvarChecker Checker(*
this, CurMethod, IV);
4875 Checker.TraverseStmt(CurMethod->getBody());
4876 if (Checker.AccessedIvar)
4883 if (!IV->
isReferenced() || !Checker.InvokedSelfMethod) {
4884 Diag(Loc, DIAG) << IV;
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.
void setImplicit(bool I=true)
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
The receiver is an object instance.
void setEndOfDefinitionLoc(SourceLocation LE)
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)
Represents a version number in the form major[.minor[.subminor[.build]]].
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.
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple()) const
Determine the availability of the given declaration.
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.
Decl - This represents one declaration (or definition), e.g.
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 isHidden() const
Determine whether this declaration might be hidden from name lookup.
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...
SourceLocation getLocEnd() const LLVM_READONLY
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.
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.
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled...
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.
static const NamedDecl * getDefinition(const Decl *D)
ParmVarDecl - Represents a parameter to a function.
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
static void checkObjCMethodX86VectorTypes(Sema &SemaRef, const ObjCMethodDecl *Method)
Verify that the method parameters/return value have types that are supported by the x86 target...
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.
bool isReferenced() const
Whether any declaration of this entity was referenced.
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
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
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.
const TargetInfo & getTargetInfo() const
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
ObjCContainerDecl - Represents a container for method declarations.
const LangOptions & getLangOpts() const
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
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.
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)
AvailabilityResult
Captures the result of checking the availability of a declaration.
static Decl::ObjCDeclQualifier CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal)
CvtQTToAstBitMask - utility routine to produce an AST bitmask for objective-c's type qualifier from t...
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
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
static void DiagnoseObjCImplementedDeprecations(Sema &S, const NamedDecl *ND, SourceLocation ImplLoc)
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
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)
DeclContext * getDeclContext()
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.
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 '@'.
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
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 setTopLevelDeclInObjCContainer(bool V=true)
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
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)
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
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.
ASTContext & getASTContext() const
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...
Decl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, AttributeList *AttrList)
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method, and set any properties that should be inherited.
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
void ActOnTypedefedProtocols(SmallVectorImpl< Decl * > &ProtocolRefs, SmallVectorImpl< SourceLocation > &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc)
ActOnTypedefedProtocols - this action finds protocol list as part of the typedef'ed use for a qualifi...
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)
bool isFileContext() const
bool ObjCIsDesignatedInit
True when this is a method marked as a designated initializer.
bool isVectorType() const
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.
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 isInvalidDecl() const
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)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
TypeParamListContext
The context in which an Objective-C type parameter list occurs, for use in diagnostics.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
Represents the declaration of an Objective-C type parameter.
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())
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
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).
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
Represents a pointer to an Objective C object.
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
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
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 isCompilingModule() const
Are we compiling a module interface (.cppm or module map)?
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.
SourceLocation getLocation() const
void setLexicalDeclContext(DeclContext *DC)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static SourceRange getTypeRange(TypeSourceInfo *TSI)
NamedDecl - This represents a decl with a name.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
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.
SourceLocation getLocStart() const LLVM_READONLY
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).
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
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
const ObjCInterfaceDecl * getSuperClass() const