29 #include "llvm/ADT/DenseMap.h"
30 #include "llvm/ADT/DenseSet.h"
33 using namespace clang;
63 assert(resultClass &&
"unexpected object type!");
68 if (receiverTypeIfCall.
isNull() &&
78 if (receiverTypeIfCall.
isNull())
85 if (!receiverClass)
return false;
88 assert(receiverClass &&
"method not associated with a class!");
104 "init method returns a type unrelated to its receiver type",
110 Diag(loc, diag::err_arc_init_method_unrelated_result_type);
132 CurrentClass = Cat->getClassInterface();
133 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(DC))
134 CurrentClass = Impl->getClassInterface();
136 = dyn_cast<ObjCCategoryImplDecl>(DC))
137 CurrentClass = CatImpl->getClassInterface();
142 diag::warn_related_result_type_compatibility_class)
148 diag::warn_related_result_type_compatibility_protocol)
155 diag::note_related_result_type_family)
160 diag::note_related_result_type_overridden);
163 if ((NewMethod->
hasAttr<NSReturnsRetainedAttr>() !=
164 Overridden->
hasAttr<NSReturnsRetainedAttr>())) {
166 diag::err_nsreturns_retained_attribute_mismatch) << 1;
170 if ((NewMethod->
hasAttr<NSReturnsNotRetainedAttr>() !=
171 Overridden->
hasAttr<NSReturnsNotRetainedAttr>())) {
173 diag::err_nsreturns_retained_attribute_mismatch) << 0;
181 ni != ne && oi != oe; ++ni, ++oi) {
184 if (newDecl->
hasAttr<NSConsumedAttr>() !=
185 oldDecl->
hasAttr<NSConsumedAttr>()) {
187 diag::err_nsconsumed_attribute_mismatch);
235 if (method->
hasAttr<NSReturnsRetainedAttr>())
243 if (method->
hasAttr<NSReturnsRetainedAttr>() ||
244 method->
hasAttr<NSReturnsNotRetainedAttr>() ||
245 method->
hasAttr<NSReturnsAutoreleasedAttr>())
259 S.
Diag(ImplLoc, diag::warn_deprecated_def) << select;
329 for (
auto *Param : MDecl->
params()) {
330 if (!Param->isInvalidDecl() &&
333 Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
336 if (Param->getIdentifier())
379 ImplDeclOfMethodDecl = OID->getImplementation();
380 else if (
ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContDeclOfMethodDecl)) {
381 if (CD->IsClassExtension()) {
383 ImplDeclOfMethodDecl = OID->getImplementation();
385 ImplDeclOfMethodDecl = CD->getImplementation();
389 if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
391 dyn_cast<NamedDecl>(IMD),
399 IC->getSuperClass() !=
nullptr;
400 }
else if (IC->hasDesignatedInitializers()) {
426 (SuperMethod && SuperMethod->
hasAttr<ObjCRequiresSuperAttr>());
439 ObjCInterfaceValidatorCCC() : CurrentIDecl(nullptr) {}
441 : CurrentIDecl(IDecl) {}
443 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
457 unsigned NumProtoRefs,
462 for (
unsigned i = 0; i < NumProtoRefs; ++i) {
487 NULL, llvm::make_unique<ObjCInterfaceValidatorCCC>(IDecl),
490 << SuperName << ClassName);
496 Diag(SuperLoc, diag::err_recursive_superclass)
497 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
501 dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
505 if (SuperClassDecl) {
510 if (PrevDecl && SuperClassDecl == 0) {
514 dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
515 QualType T = TDecl->getUnderlyingType();
535 if (!SuperClassDecl) {
536 Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
541 if (!dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
543 Diag(SuperLoc, diag::err_undef_superclass)
544 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
547 diag::err_forward_superclass,
550 SourceRange(AtInterfaceLoc, ClassLoc))) {
556 if (SuperClassType.isNull()) {
557 assert(!SuperClassDecl &&
"Failed to set SuperClassType?");
563 if (!SuperTypeArgs.empty()) {
571 SuperTypeArgsRange.
getEnd(),
583 if (!SuperClassTInfo) {
603 if (parsedTypeBound) {
614 diag::err_objc_type_param_bound_missing_pointer)
615 << typeBound << paramName
634 diag::err_objc_type_param_bound_nonobject)
635 << typeBound << paramName;
638 typeBoundInfo =
nullptr;
650 = nullabilityLoc.
isValid()? nullabilityLoc
652 Diag(diagLoc, diag::err_type_param_bound_explicit_nullability)
653 << paramName << typeBoundInfo->
getType()
661 if (!typeBoundInfo) {
668 index, paramLoc, paramName, colonLoc,
679 reinterpret_cast<ObjCTypeParamDecl * const *>(typeParamsIn.data()),
680 typeParamsIn.size());
686 llvm::SmallDenseMap<IdentifierInfo *, ObjCTypeParamDecl *> knownParams;
687 for (
auto typeParam : typeParams) {
688 auto known = knownParams.find(typeParam->getIdentifier());
689 if (known != knownParams.end()) {
690 Diag(typeParam->getLocation(), diag::err_objc_type_param_redecl)
691 << typeParam->getIdentifier()
694 typeParam->setInvalidDecl();
696 knownParams.insert(std::make_pair(typeParam->getIdentifier(), typeParam));
708 for (
auto typeParam : *typeParamList) {
709 if (!typeParam->isInvalidDecl()) {
735 if (prevTypeParams->
size() != newTypeParams->
size()) {
737 if (newTypeParams->
size() > prevTypeParams->
size()) {
743 S.
Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
744 <<
static_cast<unsigned>(newContext)
745 << (newTypeParams->
size() > prevTypeParams->
size())
746 << prevTypeParams->
size()
747 << newTypeParams->
size();
753 for (
unsigned i = 0, n = prevTypeParams->
size(); i != n; ++i) {
760 newContext != TypeParamListContext::Definition) {
779 auto diag = S.
Diag(diagLoc,
780 diag::err_objc_type_param_variance_conflict)
781 <<
static_cast<unsigned>(newTypeParam->
getVariance())
783 <<
static_cast<unsigned>(prevTypeParam->
getVariance())
792 StringRef newVarianceStr
799 (newVarianceStr +
" ").str());
826 S.
Diag(newBoundRange.
getBegin(), diag::err_objc_type_param_bound_conflict)
851 if (newContext == TypeParamListContext::ForwardDeclaration ||
852 newContext == TypeParamListContext::Definition) {
860 diag::err_objc_type_param_bound_missing)
863 << (newContext == TypeParamListContext::ForwardDeclaration)
885 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
888 assert(ClassName &&
"Missing class identifier");
894 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
895 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
926 TypeParamListContext::Definition)) {
927 typeParamList =
nullptr;
930 Diag(ClassLoc, diag::err_objc_parameterized_forward_class_first)
932 Diag(prevTypeParamList->getLAngleLoc(), diag::note_previous_decl)
937 for (
auto typeParam : *prevTypeParamList) {
938 clonedTypeParams.push_back(
942 typeParam->getVariance(),
944 typeParam->getIndex(),
946 typeParam->getIdentifier(),
961 typeParamList, PrevIDecl, ClassLoc);
965 Diag(AtInterfaceLoc, diag::err_duplicate_class_def)
967 Diag(Def->getLocation(), diag::note_previous_definition);
987 SuperName, SuperLoc, SuperTypeArgs,
996 NumProtoRefs, ProtoLocs);
1019 if (
const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) {
1020 QualType T = TDecl->getUnderlyingType();
1023 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end());
1038 Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
1046 dyn_cast_or_null<TypedefNameDecl>(CDeclU)) {
1047 QualType T = TDecl->getUnderlyingType();
1050 ClassName = IDecl->getIdentifier();
1058 Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
1081 E = PList.
end(); I != E; ++I) {
1084 if (PDecl->getIdentifier() == PName) {
1085 Diag(Ploc, diag::err_protocol_has_circular_dependency);
1086 Diag(PrevLoc, diag::note_previous_definition);
1090 if (!PDecl->hasDefinition())
1094 PDecl->getLocation(), PDecl->getReferencedProtocols()))
1105 Decl *
const *ProtoRefs,
1106 unsigned NumProtoRefs,
1112 assert(ProtocolName &&
"Missing protocol identifier");
1118 Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName;
1119 Diag(Def->getLocation(), diag::note_previous_definition);
1126 ProtocolLoc, AtProtoInterfaceLoc,
1128 PDecl->startDefinition();
1136 ProtocolName, ProtocolLoc, PrevDecl->
getLocation(), PList);
1141 ProtocolLoc, AtProtoInterfaceLoc,
1155 if (!err && NumProtoRefs ) {
1158 NumProtoRefs, ProtoLocs);
1170 UndefinedProtocol = PDecl;
1176 UndefinedProtocol = PI;
1188 unsigned NumProtocols,
1190 for (
unsigned i = 0; i != NumProtocols; ++i) {
1192 ProtocolId[i].second);
1201 << ProtocolId[i].first);
1205 Diag(ProtocolId[i].second, diag::err_undeclared_protocol)
1206 << ProtocolId[i].first;
1215 if (!ForObjCContainer) {
1224 if (WarnOnDeclarations &&
1226 Diag(ProtocolId[i].second, diag::warn_undef_protocolref)
1227 << ProtocolId[i].first;
1228 Diag(UndefinedProtocol->
getLocation(), diag::note_protocol_decl_undefined)
1229 << UndefinedProtocol;
1231 Protocols.push_back(PDecl);
1242 ObjCTypeArgOrProtocolValidatorCCC(
ASTContext &context,
1244 :
Context(context), LookupKind(lookupKind) { }
1246 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
1266 if (
type->isObjCObjectPointerType() ||
1267 type->isBlockPointerType() ||
1268 type->isDependentType() ||
1269 type->isObjCObjectType())
1301 bool warnOnIncompleteProtocols) {
1304 unsigned numProtocolsResolved = 0;
1305 auto resolvedAsProtocols = [&] {
1306 assert(numProtocolsResolved == identifiers.size() &&
"Unresolved protocols");
1313 bool allAreTypeNames =
false;
1317 baseClass = objcObjectType->getInterface();
1319 if (
auto typeParams = baseClass->getTypeParamList()) {
1320 if (typeParams->size() == numProtocolsResolved) {
1322 allAreTypeNames =
true;
1329 for (
unsigned i = 0, n = protocols.size(); i != n; ++i) {
1334 if (!warnOnIncompleteProtocols) {
1346 if (warnOnIncompleteProtocols &&
1348 Diag(identifierLocs[i], diag::warn_undef_protocolref)
1357 if (allAreTypeNames) {
1360 if (isa<ObjCInterfaceDecl>(
decl)) {
1362 firstClassNameLoc = identifierLocs[i];
1363 }
else if (!isa<TypeDecl>(
decl)) {
1365 allAreTypeNames =
false;
1368 allAreTypeNames =
false;
1377 if (allAreTypeNames && firstClassNameLoc.
isValid()) {
1378 llvm::SmallPtrSet<ObjCProtocolDecl*, 8> knownProtocols;
1380 bool allProtocolsDeclared =
true;
1381 for (
auto proto : protocols) {
1382 if (knownProtocols.count(static_cast<ObjCProtocolDecl *>(proto)) == 0) {
1383 allProtocolsDeclared =
false;
1388 if (allProtocolsDeclared) {
1389 Diag(firstClassNameLoc, diag::warn_objc_redundant_qualified_class_type)
1390 << baseClass->getDeclName() <<
SourceRange(lAngleLoc, rAngleLoc)
1396 protocolLAngleLoc = lAngleLoc;
1397 protocolRAngleLoc = rAngleLoc;
1398 assert(protocols.size() == identifierLocs.size());
1402 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1404 protocols.push_back(proto);
1406 ++numProtocolsResolved;
1410 if (numProtocolsResolved == identifiers.size())
1411 return resolvedAsProtocols();
1417 typedef llvm::PointerUnion<TypeDecl *, ObjCInterfaceDecl *> TypeOrClassDecl;
1419 unsigned numTypeDeclsResolved = 0;
1420 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1424 typeDecls.push_back(TypeOrClassDecl());
1428 if (
auto typeDecl = dyn_cast<TypeDecl>(decl)) {
1429 typeDecls.push_back(typeDecl);
1430 ++numTypeDeclsResolved;
1434 if (
auto objcClass = dyn_cast<ObjCInterfaceDecl>(decl)) {
1435 typeDecls.push_back(objcClass);
1436 ++numTypeDeclsResolved;
1440 typeDecls.push_back(TypeOrClassDecl());
1447 auto resolveTypeReference = [&](TypeOrClassDecl typeDecl,
SourceLocation loc)
1451 const char* prevSpec;
1454 if (
auto *actualTypeDecl = typeDecl.dyn_cast<
TypeDecl *>())
1483 Diag(loc, diag::err_objc_type_arg_missing_star)
1494 auto resolvedAsTypeDecls = [&] {
1498 assert(numTypeDeclsResolved == identifiers.size() &&
"Unresolved type decl");
1500 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1502 TypeResult type = resolveTypeReference(typeDecls[i], identifierLocs[i]);
1508 typeArgs.push_back(type.
get());
1511 typeArgsLAngleLoc = lAngleLoc;
1512 typeArgsRAngleLoc = rAngleLoc;
1517 if (numTypeDeclsResolved == identifiers.size())
1518 return resolvedAsTypeDecls();
1524 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1527 if (protocols[i] || typeDecls[i]) {
1533 if (protocols[i] && typeDecls[i])
1555 Diag(identifierLocs[i], diag::err_objc_type_args_and_protocols)
1556 << (protocols[i] !=
nullptr)
1570 llvm::make_unique<ObjCTypeArgOrProtocolValidatorCCC>(
Context,
1577 PDiag(diag::err_undeclared_protocol_suggest)
1580 protocols[i] = proto;
1581 ++numProtocolsResolved;
1588 PDiag(diag::err_unknown_typename_suggest)
1591 typeDecls[i] = typeDecl;
1592 ++numTypeDeclsResolved;
1599 PDiag(diag::err_unknown_type_or_class_name_suggest)
1600 << identifiers[i] <<
true);
1602 typeDecls[i] = objcClass;
1603 ++numTypeDeclsResolved;
1609 Diag(identifierLocs[i],
1610 (lookupKind ==
LookupAnyName ? diag::err_objc_type_arg_missing
1612 : diag::err_unknown_typename))
1621 if (numProtocolsResolved == identifiers.size())
1622 return resolvedAsProtocols();
1625 assert(numTypeDeclsResolved == identifiers.size() &&
"Not all types?");
1626 return resolvedAsTypeDecls();
1637 llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
1638 for (
auto *MD : ID->
methods())
1639 MethodMap[MD->getSelector()] = MD;
1641 if (MethodMap.empty())
1643 for (
const auto *Method : CAT->
methods()) {
1644 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()];
1648 Diag(Method->getLocation(), diag::err_duplicate_method_decl)
1649 << Method->getDeclName();
1662 for (
unsigned i = 0; i != NumElts; ++i) {
1668 IdentList[i].second, AtProtocolLoc,
1680 DeclsInGroup.push_back(PDecl);
1692 Decl *
const *ProtoRefs,
1693 unsigned NumProtoRefs,
1703 diag::err_category_forward_interface,
1704 CategoryName ==
nullptr)) {
1709 ClassLoc, CategoryLoc, CategoryName,
1710 IDecl, typeParamList);
1715 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1720 Diag(ClassLoc, diag::err_class_extension_after_impl) << ClassName;
1722 diag::note_implementation_declared);
1730 Diag(CategoryLoc, diag::warn_dup_category_def)
1731 << ClassName << CategoryName;
1732 Diag(
Previous->getLocation(), diag::note_previous_definition);
1737 if (typeParamList) {
1741 ? TypeParamListContext::Category
1742 : TypeParamListContext::Extension))
1743 typeParamList =
nullptr;
1746 diag::err_objc_parameterized_category_nonclass)
1747 << (CategoryName !=
nullptr)
1751 typeParamList =
nullptr;
1756 ClassLoc, CategoryLoc, CategoryName, IDecl,
1763 NumProtoRefs, ProtoLocs);
1800 ClassLoc, AtCatImplLoc, CatLoc);
1803 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1806 diag::err_undef_interface)) {
1820 Diag(ClassLoc, diag::err_dup_implementation_category) << ClassName
1823 diag::note_previous_definition);
1830 dyn_cast<NamedDecl>(IDecl),
1849 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1850 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
1852 }
else if ((IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl))) {
1854 diag::warn_undef_interface);
1860 nullptr, llvm::make_unique<ObjCInterfaceValidatorCCC>(),
CTK_NonError);
1866 PDiag(diag::warn_undef_interface_suggest) << ClassName,
1869 Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
1875 if (SuperClassname) {
1879 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
1880 Diag(SuperClassLoc, diag::err_redefinition_different_kind)
1884 SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
1888 Diag(SuperClassLoc, diag::err_undef_superclass)
1889 << SuperClassname << ClassName;
1893 Diag(SuperClassLoc, diag::err_conflicting_super_class)
1931 ClassLoc, AtClassImplLoc, SuperClassLoc);
1939 Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
1941 diag::note_previous_definition);
1949 dyn_cast<NamedDecl>(IDecl),
1958 DeclsInGroup.reserve(Decls.size() + 1);
1960 for (
unsigned i = 0, e = Decls.size(); i != e; ++i) {
1961 Decl *Dcl = Decls[i];
1966 DeclsInGroup.push_back(Dcl);
1969 DeclsInGroup.push_back(ObjCImpDecl);
1977 assert(ImpDecl &&
"missing implementation decl");
1987 for (
unsigned i = 0, e = numIvars; i != e; ++i) {
1999 assert(ivars &&
"missing @implementation ivars");
2003 for (
unsigned i = 0; i < numIvars; i++) {
2008 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2016 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
2033 for (; numIvars > 0 && IVI != IVE; ++IVI) {
2036 assert (ImplIvar &&
"missing implementation ivar");
2037 assert (ClsIvar &&
"missing class ivar");
2049 diag::err_conflicting_ivar_bitwidth) << ImplIvar->
getIdentifier();
2051 diag::note_previous_definition);
2063 Diag(ivars[j]->getLocation(), diag::err_inconsistent_ivar_count);
2064 else if (IVI != IVE)
2065 Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
2070 bool &IncompleteImpl,
2100 S.
Diag(MethodLoc, diag::note_method_declared_at) << method;
2178 (y & ~
Decl::OBJC_TQ_CSNullability);
2184 bool IsProtocolMethodDecl,
2185 bool IsOverridingMode,
2187 if (IsProtocolMethodDecl &&
2193 ? diag::warn_conflicting_overriding_ret_type_modifiers
2194 : diag::warn_conflicting_ret_type_modifiers))
2203 if (Warn && IsOverridingMode &&
2208 auto nullabilityMethodImpl =
2210 auto nullabilityMethodDecl =
2213 diag::warn_conflicting_nullability_attr_overriding_ret_types)
2215 nullabilityMethodImpl,
2219 nullabilityMethodDecl,
2232 IsOverridingMode ? diag::warn_conflicting_overriding_ret_types
2233 : diag::warn_conflicting_ret_types;
2249 IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types
2250 : diag::warn_non_covariant_ret_types;
2259 ? diag::note_previous_declaration
2260 : diag::note_previous_definition)
2270 bool IsProtocolMethodDecl,
2271 bool IsOverridingMode,
2273 if (IsProtocolMethodDecl &&
2277 if (IsOverridingMode)
2279 diag::warn_conflicting_overriding_param_modifiers)
2283 diag::warn_conflicting_param_modifiers)
2295 if (Warn && IsOverridingMode &&
2299 diag::warn_conflicting_nullability_attr_overriding_param_types)
2316 IsOverridingMode ? diag::warn_conflicting_overriding_param_types
2317 : diag::warn_conflicting_param_types;
2333 IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types
2334 : diag::warn_non_contravariant_param_types;
2340 << MethodImpl->
getDeclName() << IfaceTy << ImplTy;
2342 (IsOverridingMode ? diag::note_previous_declaration
2343 : diag::note_previous_definition))
2354 if (implFamily == declFamily)
return false;
2366 unsigned errorID = diag::err_arc_lost_method_convention;
2367 unsigned noteID = diag::note_arc_lost_method_convention;
2370 family = implFamily;
2371 errorID = diag::err_arc_gained_method_convention;
2372 noteID = diag::note_arc_gained_method_convention;
2376 enum FamilySelector {
2377 F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new
2379 FamilySelector familySelector = FamilySelector();
2382 case OMF_None: llvm_unreachable(
"logic error, no method convention");
2396 case OMF_init: familySelector = F_init;
break;
2397 case OMF_alloc: familySelector = F_alloc;
break;
2398 case OMF_copy: familySelector = F_copy;
break;
2400 case OMF_new: familySelector = F_new;
break;
2403 enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn };
2404 ReasonSelector reasonSelector;
2409 reasonSelector = R_UnrelatedReturn;
2411 reasonSelector = R_NonObjectReturn;
2414 S.
Diag(impl->
getLocation(), errorID) <<
int(familySelector) << int(reasonSelector);
2415 S.
Diag(decl->
getLocation(), noteID) <<
int(familySelector) << int(reasonSelector);
2422 bool IsProtocolMethodDecl) {
2428 IsProtocolMethodDecl,
false,
2434 IM != EM && IF != EF; ++IM, ++IF) {
2436 IsProtocolMethodDecl,
false,
true);
2441 diag::warn_conflicting_variadic);
2448 bool IsProtocolMethodDecl) {
2451 IsProtocolMethodDecl,
true,
2457 IM != EM && IF != EF; ++IM, ++IF) {
2459 IsProtocolMethodDecl,
true,
true);
2464 diag::warn_conflicting_overriding_variadic);
2473 bool IsProtocolMethodDecl) {
2481 if (MethodDecl->
hasAttr<UnavailableAttr>() ||
2482 MethodDecl->
hasAttr<DeprecatedAttr>())
2486 IsProtocolMethodDecl,
false,
false);
2491 IM != EM && IF != EF; ++IM, ++IF) {
2494 IsProtocolMethodDecl,
false,
false);
2506 diag::warn_category_method_impl_match);
2523 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>())
2525 for (
const auto *PI : PDecl->
protocols())
2548 bool& IncompleteImpl,
2556 assert (IDecl &&
"CheckProtocolMethodDefs - IDecl is null");
2572 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>()) {
2573 if (!ProtocolsExplictImpl) {
2578 ProtocolsExplictImpl->end())
2596 if (InsMap.count(fISelector))
2616 !method->isPropertyAccessor() &&
2617 !InsMap.count(method->getSelector()) &&
2633 IDecl->lookupMethod(method->getSelector(),
2637 if (C || MethodInClass->isPropertyAccessor())
2639 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2649 !ClsMap.count(method->getSelector()) &&
2656 if (C && IDecl->lookupMethod(method->getSelector(),
2662 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2671 CDecl, ProtocolsExplictImpl);
2683 bool &IncompleteImpl,
2684 bool ImmediateClass,
2685 bool WarnCategoryMethodImpl) {
2689 if (!InsMapSeen.insert(I->getSelector()).second)
2691 if (!I->isPropertyAccessor() &&
2692 !InsMap.count(I->getSelector())) {
2695 diag::warn_undef_method_impl);
2701 "Expected to find the method through lookup as well");
2703 if (ImpMethodDecl) {
2704 if (!WarnCategoryMethodImpl)
2706 isa<ObjCProtocolDecl>(CDecl));
2707 else if (!I->isPropertyAccessor())
2716 if (!ClsMapSeen.insert(I->getSelector()).second)
2718 if (!ClsMap.count(I->getSelector())) {
2721 diag::warn_undef_method_impl);
2726 "Expected to find the method through lookup as well");
2727 if (!WarnCategoryMethodImpl)
2729 isa<ObjCProtocolDecl>(CDecl));
2732 isa<ObjCProtocolDecl>(CDecl));
2739 for (
auto *PI : PD->protocols())
2741 IMPDecl, PI, IncompleteImpl,
false,
2742 WarnCategoryMethodImpl);
2749 if (!WarnCategoryMethodImpl) {
2750 for (
auto *Cat : I->visible_categories())
2752 IMPDecl, Cat, IncompleteImpl,
false,
2753 WarnCategoryMethodImpl);
2756 for (
auto *Ext : I->visible_extensions())
2758 IMPDecl, Ext, IncompleteImpl,
false,
2759 WarnCategoryMethodImpl);
2763 for (
auto *PI : I->all_referenced_protocols())
2765 IMPDecl, PI, IncompleteImpl,
false,
2766 WarnCategoryMethodImpl);
2770 if (!WarnCategoryMethodImpl && I->getSuperClass())
2773 I->getSuperClass(), IncompleteImpl,
false);
2804 if (SuperIDecl && SuperIDecl->
lookupMethod(Sel,
false))
2808 if (InsMap.empty() && ClsMap.empty())
2812 bool IncompleteImpl =
false;
2815 IncompleteImpl,
false,
2821 bool IncompleteImpl) {
2826 InsMap.insert(I->getSelector());
2832 bool SynthesizeProperties =
LangOpts.ObjCDefaultSynthProperties &&
2834 !IDecl->isObjCRequiresPropertyDefs();
2843 ClsMap.insert(I->getSelector());
2850 IncompleteImpl,
true);
2855 dyn_cast<ObjCCategoryImplDecl>(IMPDecl))
2866 for (
auto *PI : I->all_referenced_protocols())
2868 InsMap, ClsMap, I, ExplicitImplProtocols);
2870 for (
auto *Ext : I->visible_extensions())
2875 if (!
C->IsClassExtension()) {
2876 for (
auto *
P :
C->protocols())
2878 IncompleteImpl, InsMap, ClsMap, CDecl,
2879 ExplicitImplProtocols);
2884 llvm_unreachable(
"invalid ObjCContainerDecl type.");
2894 for (
unsigned i = 0; i != NumElts; ++i) {
2899 if (PrevDecl && !isa<ObjCInterfaceDecl>(PrevDecl)) {
2909 Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
2917 Diag(AtClassLoc, diag::warn_forward_class_redefinition)
2927 = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
2949 if (PrevIDecl && TypeParams) {
2953 *
this, PrevTypeParams, TypeParams,
2954 TypeParamListContext::ForwardDeclaration)) {
2955 TypeParams =
nullptr;
2959 Diag(IdentLocs[i], diag::err_objc_parameterized_forward_class)
2962 Diag(Def->getLocation(), diag::note_defined_here)
2965 TypeParams =
nullptr;
2971 ClassName, TypeParams, PrevIDecl,
2977 DeclsInGroup.push_back(IDecl);
2985 const Type *left,
const Type *right);
2994 if (left == right)
return true;
3017 if (isa<VectorType>(left))
return isa<VectorType>(right);
3018 if (isa<VectorType>(right))
return false;
3041 return (leftSK == rightSK);
3047 assert(lt && rt && lt != rt);
3049 if (!isa<RecordType>(lt) || !isa<RecordType>(rt))
return false;
3050 RecordDecl *left = cast<RecordType>(lt)->getDecl();
3051 RecordDecl *right = cast<RecordType>(rt)->getDecl();
3057 if ((isa<CXXRecordDecl>(left) && !cast<CXXRecordDecl>(left)->isPOD()) ||
3058 (isa<CXXRecordDecl>(right) && !cast<CXXRecordDecl>(right)->isPOD()))
3073 for (; li != le && ri != re; ++li, ++ri) {
3074 if (!
matchTypes(Context, strategy, li->getType(), ri->getType()))
3077 return (li == le && ri == re);
3095 (left->
hasAttr<NSReturnsRetainedAttr>()
3096 != right->
hasAttr<NSReturnsRetainedAttr>() ||
3097 left->
hasAttr<NSConsumesSelfAttr>()
3098 != right->
hasAttr<NSConsumesSelfAttr>()))
3105 for (; li != le && ri != re; ++li, ++ri) {
3106 assert(ri != right->
param_end() &&
"Param mismatch");
3113 lparm->hasAttr<NSConsumedAttr>() != rparm->hasAttr<NSConsumedAttr>())
3125 if (!CD->IsClassExtension() && List->
getBits() < 2)
3138 for (; List; Previous = List, List = List->
getNext()) {
3162 List->setHasMoreThanOneDecl(
true);
3169 List->setMethod(Method);
3175 List->setMethod(Method);
3190 assert(ExternalSource &&
"We need an external AST source");
3194 void Sema::AddMethodToGlobalPool(
ObjCMethodDecl *Method,
bool impl,
3210 ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second;
3238 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3242 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
3244 if (M->getMethod() && !M->getMethod()->isHidden())
3245 Methods.push_back(M->getMethod());
3246 return Methods.size() > 1;
3251 bool receiverIdOrClass) {
3252 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3262 Methods.push_back(BestMethod);
3265 if (!M->isHidden() && M != BestMethod && !M->
hasAttr<UnavailableAttr>())
3266 Methods.push_back(M);
3267 if (Methods.size() > 1)
3274 bool receiverIdOrClass,
3279 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3284 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
3287 if (M->getMethod() && !M->getMethod()->isHidden())
3288 return M->getMethod();
3295 bool receiverIdOrClass) {
3297 bool issueDiagnostic =
false, issueError =
false;
3301 bool strictSelectorMatch =
3302 receiverIdOrClass &&
3304 if (strictSelectorMatch) {
3305 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3307 issueDiagnostic =
true;
3316 if (!strictSelectorMatch ||
3317 (issueDiagnostic &&
getLangOpts().ObjCAutoRefCount))
3318 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3322 issueDiagnostic =
true;
3329 if (issueDiagnostic) {
3331 Diag(R.
getBegin(), diag::err_arc_multiple_method_decl) << Sel << R;
3332 else if (strictSelectorMatch)
3333 Diag(R.
getBegin(), diag::warn_strict_multiple_method_decl) << Sel << R;
3335 Diag(R.
getBegin(), diag::warn_multiple_method_decl) << Sel << R;
3337 Diag(Methods[0]->getLocStart(),
3338 issueError ? diag::note_possibility : diag::note_using)
3339 << Methods[0]->getSourceRange();
3340 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3341 Diag(Methods[I]->getLocStart(), diag::note_also_found)
3342 << Methods[I]->getSourceRange();
3348 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3354 Method = Method->getNext())
3355 if (Method->getMethod() &&
3358 return Method->getMethod();
3361 Method = Method->getNext())
3362 if (Method->getMethod() &&
3365 return Method->getMethod();
3377 unsigned MinPossibleEditDistance = abs((
int)MethodName.size() - (int)Typo.size());
3378 if (MinPossibleEditDistance > 0 &&
3379 Typo.size() / MinPossibleEditDistance < 1)
3381 unsigned EditDistance = Typo.edit_distance(MethodName,
true, MaxEditDistance);
3382 if (EditDistance > MaxEditDistance)
3384 if (EditDistance == BestEditDistance)
3385 BestMethod.push_back(Method);
3386 else if (EditDistance < BestEditDistance) {
3388 BestMethod.push_back(Method);
3407 bool ObjectIsId =
true, ObjectIsClass =
true;
3409 ObjectIsId = ObjectIsClass =
false;
3414 ObjectType =
QualType(ObjCPtr->getInterfaceType(), 0);
3415 ObjectIsId = ObjectIsClass =
false;
3418 ObjectIsClass =
false;
3424 for (GlobalMethodPool::iterator b =
MethodPool.begin(),
3428 if (M->getMethod() &&
3429 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3430 (M->getMethod()->getSelector() != Sel)) {
3432 Methods.push_back(M->getMethod());
3433 else if (!ObjectIsClass &&
3436 Methods.push_back(M->getMethod());
3440 if (M->getMethod() &&
3441 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3442 (M->getMethod()->getSelector() != Sel)) {
3444 Methods.push_back(M->getMethod());
3445 else if (!ObjectIsId &&
3448 Methods.push_back(M->getMethod());
3453 for (
unsigned i = 0, e = Methods.size(); i < e; i++) {
3457 return (SelectedMethods.size() == 1) ? SelectedMethods[0] :
nullptr;
3467 for (
auto *Ivar : ID->
ivars()) {
3468 if (Ivar->isInvalidDecl())
3473 Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
3475 Ivar->setInvalidDecl();
3483 case Decl::ObjCInterface:
3485 case Decl::ObjCProtocol:
3487 case Decl::ObjCCategory:
3488 if (cast<ObjCCategoryDecl>(
CurContext)->IsClassExtension())
3491 case Decl::ObjCImplementation:
3493 case Decl::ObjCCategoryImpl:
3507 assert(AtEnd.
isValid() &&
"Invalid location for '@end'");
3510 Decl *ClassDecl = cast<Decl>(OCD);
3512 bool isInterfaceDeclKind =
3513 isa<ObjCInterfaceDecl>(ClassDecl) || isa<ObjCCategoryDecl>(ClassDecl)
3514 || isa<ObjCProtocolDecl>(ClassDecl);
3515 bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
3518 llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap;
3519 llvm::DenseMap<Selector, const ObjCMethodDecl*> ClsMap;
3521 for (
unsigned i = 0, e = allMethods.size(); i != e; i++ ) {
3523 cast_or_null<ObjCMethodDecl>(allMethods[i]);
3525 if (!Method)
continue;
3531 if ((isInterfaceDeclKind && PrevMethod && !match)
3532 || (checkIdenticalMethods && match)) {
3555 if ((isInterfaceDeclKind && PrevMethod && !match)
3556 || (checkIdenticalMethods && match)) {
3575 if (isa<ObjCInterfaceDecl>(ClassDecl)) {
3582 if (
C->IsClassExtension()) {
3588 if (CDecl->getIdentifier())
3592 for (
auto *I : CDecl->properties())
3594 CDecl->setAtEndRange(AtEnd);
3597 IC->setAtEndRange(AtEnd);
3604 for (
const auto *Ext : IDecl->visible_extensions()) {
3605 for (
const auto *
Property : Ext->properties()) {
3608 = IC->FindPropertyImplDecl(
Property->getIdentifier()))
3609 if (PIDecl->getPropertyImplementation()
3613 for (
const auto *Ext : IDecl->visible_extensions()) {
3615 = Ext->getInstanceMethod(
Property->getGetterName()))
3616 GetterMethod->setPropertyAccessor(
true);
3619 = Ext->getInstanceMethod(
Property->getSetterName()))
3620 SetterMethod->setPropertyAccessor(
true);
3628 if (IDecl->hasDesignatedInitializers())
3631 bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>();
3632 if (IDecl->getSuperClass() ==
nullptr) {
3635 if (!HasRootClassAttr) {
3638 Diag(DeclLoc, diag::warn_objc_root_class_missing)
3639 << IDecl->getIdentifier();
3646 if (NSObjectDecl && NSObjectDecl->getDefinition()) {
3647 Diag(SuperClassLoc, diag::note_objc_needs_superclass)
3650 Diag(SuperClassLoc, diag::note_objc_needs_superclass);
3653 }
else if (HasRootClassAttr) {
3655 Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass);
3659 while (IDecl->getSuperClass()) {
3661 IDecl = IDecl->getSuperClass();
3667 dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
3668 CatImplClass->setAtEndRange(AtEnd);
3674 = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier())) {
3679 if (isInterfaceDeclKind) {
3681 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
3684 if (
VarDecl *VDecl = dyn_cast<VarDecl>(*I)) {
3685 if (!VDecl->hasExternalStorage())
3686 Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass);
3692 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
3695 (*I)->setTopLevelDeclInObjCContainer();
3725 if (ResultObjectType->isObjCIdType() ||
3726 ResultObjectType->isObjCQualifiedIdType())
3731 = ResultObjectType->getInterfaceDecl()) {
3737 if (ResultClass->isSuperClassOf(CurrentClass))
3753 class OverrideSearch {
3757 llvm::SmallPtrSet<ObjCMethodDecl*, 4> Overridden;
3766 Sema::GlobalMethodPool::iterator it = S.
MethodPool.find(selector);
3786 searchFromContainer(container);
3788 searchFromContainer(Interface);
3790 searchFromContainer(container);
3794 typedef llvm::SmallPtrSet<ObjCMethodDecl*, 128>::iterator iterator;
3795 iterator begin()
const {
return Overridden.begin(); }
3796 iterator end()
const {
return Overridden.end(); }
3803 #define OBJCCONTAINER(type, base) \
3805 searchFrom(cast<type##Decl>(container)); \
3807 #define ABSTRACT_DECL(expansion)
3808 #define DECL(type, base) \
3810 #include "clang/AST/DeclNodes.inc"
3811 llvm_unreachable(
"not an ObjC container!");
3885 Overridden.insert(meth);
3895 searchFromContainer(container);
3904 OverrideSearch overrides(*
this, ObjCMethod);
3910 bool hasOverriddenMethodsInBaseOrProtocol =
false;
3911 for (OverrideSearch::iterator
3912 i = overrides.begin(), e = overrides.end(); i != e; ++i) {
3915 if (!hasOverriddenMethodsInBaseOrProtocol) {
3919 hasOverriddenMethodsInBaseOrProtocol =
true;
3929 GlobalMethodPool::iterator It =
3934 unsigned CategCount = List.
getBits();
3935 if (CategCount > 0) {
3938 if (CategCount > 1 ||
3940 OverrideSearch overrides(*
this, overridden);
3941 for (OverrideSearch::iterator
3942 OI= overrides.begin(), OE= overrides.end(); OI!=OE; ++OI) {
3946 hasOverriddenMethodsInBaseOrProtocol =
true;
3973 if (CurrentClass && overridden->
getDeclContext() != CurrentClass &&
3980 for (; ParamI != E && PrevI != PrevE; ++ParamI, ++PrevI) {
3981 assert(PrevI != overridden->
param_end() &&
"Param mismatch");
3987 Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
3996 ObjCMethod->
setOverriding(hasOverriddenMethodsInBaseOrProtocol);
4006 bool prevUsesCSKeyword) {
4012 if (nullability.hasValue() == prevNullability.hasValue()) {
4018 if (*nullability == *prevNullability)
4022 S.
Diag(loc, diag::err_nullability_conflicting)
4045 if (prevMethod->
hasAttr<ObjCRequiresSuperAttr>() &&
4046 !method->
hasAttr<ObjCRequiresSuperAttr>()) {
4049 ObjCRequiresSuperAttr::CreateImplicit(S.
Context,
4066 unsigned numPrevParams = prevMethod->
param_size();
4067 for (
unsigned i = 0, n = std::min(numParams, numPrevParams); i != n; ++i) {
4094 bool isVariadic,
bool MethodDefinition) {
4097 Diag(MethodLoc, diag::error_missing_method_context);
4101 Decl *ClassDecl = cast<Decl>(OCD);
4104 bool HasRelatedResultType =
false;
4112 QualType bareResultType = resultDeclType;
4117 Diag(MethodLoc, diag::warn_missing_method_return_type)
4123 MethodType == tok::minus, isVariadic,
4128 HasRelatedResultType);
4132 for (
unsigned i = 0, e = Sel.
getNumArgs(); i != e; ++i) {
4136 if (!ArgInfo[i].
Type) {
4143 LookupResult R(*
this, ArgInfo[i].Name, ArgInfo[i].NameLoc,
4149 Diag(ArgInfo[i].NameLoc,
4150 (MethodDefinition ? diag::warn_method_param_redefinition
4151 : diag::warn_method_param_declaration))
4154 diag::note_previous_declaration);
4163 ArgInfo[i].NameLoc, ArgInfo[i].Name,
4174 if (Param->
hasAttr<BlocksAttr>()) {
4181 Params.push_back(Param);
4184 for (
unsigned i = 0, e = CNumArgs; i != e; ++i) {
4187 if (ArgType.isNull())
4194 Params.push_back(Param);
4206 if (
ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(ClassDecl)) {
4207 if (MethodType == tok::minus) {
4208 PrevMethod = ImpDecl->getInstanceMethod(Sel);
4209 ImpDecl->addInstanceMethod(ObjCMethod);
4211 PrevMethod = ImpDecl->getClassMethod(Sel);
4212 ImpDecl->addClassMethod(ObjCMethod);
4218 if (
auto *IMD = IDecl->lookupMethod(ObjCMethod->
getSelector(),
4223 if (isa<ObjCCategoryImplDecl>(ImpDecl) && IMD->isOverriding() &&
4231 cast<DeclContext>(ClassDecl)->addDecl(ObjCMethod);
4247 if (!CurrentClass) {
4249 CurrentClass = Cat->getClassInterface();
4250 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(ClassDecl))
4251 CurrentClass = Impl->getClassInterface();
4253 = dyn_cast<ObjCCategoryImplDecl>(ClassDecl))
4254 CurrentClass = CatImpl->getClassInterface();
4262 bool ARCError =
false;
4269 LangOpts.ObjCInferRelatedResultType) {
4270 bool InferRelatedResultType =
false;
4296 if (InferRelatedResultType &&
4317 Diag(D->
getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
4331 Diag(DeclStart, diag::err_undef_interface) << ClassName;
4335 Diag(DeclStart, diag::err_atdef_nonfragile_interface);
4343 for (
unsigned i = 0; i < Ivars.size(); i++) {
4351 Decls.push_back(FD);
4356 D != Decls.end(); ++D) {
4360 else if (
RecordDecl *Record = dyn_cast<RecordDecl>(TagD))
4361 Record->addDecl(FD);
4376 Diag(IdLoc, diag::err_arg_with_address_space);
4388 Diag(IdLoc ,diag::err_catch_param_not_objc_type);
4391 Diag(IdLoc, diag::err_illegal_qualifiers_on_catch_parm);
4421 diag::err_invalid_thread)
4455 if (New->
hasAttr<BlocksAttr>())
4468 Ivars.push_back(Iv);
4474 if (ExternalSource) {
4477 for (
unsigned I = 0, N = Sels.size(); I != N; ++I)
4488 Selector Sel = SelectorAndLocation.first;
4491 Diag(Loc, diag::warn_unimplemented_selector) << Sel;
4515 IV->getIdentifier());
4524 class UnusedBackingIvarChecker :
4525 public DataRecursiveASTVisitor<UnusedBackingIvarChecker> {
4531 bool InvokedSelfMethod;
4535 : S(S), Method(Method), IvarD(IvarD),
4536 AccessedIvar(
false), InvokedSelfMethod(
false) {
4542 AccessedIvar =
true;
4551 InvokedSelfMethod =
true;
4564 unsigned DIAG = diag::warn_unused_property_backing_ivar;
4574 UnusedBackingIvarChecker Checker(*
this, CurMethod, IV);
4575 Checker.TraverseStmt(CurMethod->getBody());
4576 if (Checker.AccessedIvar)
4583 if (!IV->
isReferenced() || !Checker.InvokedSelfMethod) {
4584 Diag(Loc, DIAG) << IV;
SourceLocation getThreadStorageClassSpecLoc() const
unsigned getAddressSpace() const
getAddressSpace - Return the address space of this type.
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. If the method is implicit (not coming fro...
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)
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, ObjCInterfaceDecl *ID)
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.
bool isObjCContainer() const
ImplementationControl getImplementationControl() const
Simple class containing the result of Sema::CorrectTypo.
void setStarLoc(SourceLocation Loc)
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
ObjCInterfaceDecl * getClassInterface()
ObjCInterfaceDecl * getClassInterface()
DeclContext * getCurLexicalContext() const
void setOverriding(bool isOverriding)
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
bool isBitField() const
Determines whether this field is a bitfield.
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
SourceLocation findNullabilityLoc() const
llvm::DenseSet< IdentifierInfo * > ProtocolNameSet
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, const IdentifierLocPair *ProtocolId, unsigned NumProtocols, SmallVectorImpl< Decl * > &Protocols)
IdentifierInfo * getIdentifier() const
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)
bool isRecordType() const
QualType getUnderlyingType() const
void setHasMoreThanOneDecl(bool B)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
void DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl< ObjCMethodDecl * > &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass)
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...
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl, ObjCProtocolDecl *&UndefinedProtocol)
SCS getStorageClassSpec() const
std::string getAsString() const
bool CheckForwardProtocolDeclarationForCircularDependency(IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, const ObjCList< ObjCProtocolDecl > &PList)
bool isObjCQualifiedClassType() const
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
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
A container of type source information.
SourceLocation getLocEnd() const LLVM_READONLY
static void HelperSelectorsForTypoCorrection(SmallVectorImpl< const ObjCMethodDecl * > &BestMethod, StringRef Typo, const ObjCMethodDecl *Method)
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group, bool TypeMayContainAuto=true)
void setImplementation(ObjCCategoryImplDecl *ImplD)
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
Information about one declarator, including the parsed type information and the identifier.
DiagnosticsEngine & Diags
SourceLocation getLocStart() const LLVM_READONLY
field_iterator field_begin() const
static void WarnUndefinedMethod(Sema &S, SourceLocation ImpLoc, ObjCMethodDecl *method, bool &IncompleteImpl, unsigned DiagID, NamedDecl *NeededFor=nullptr)
SourceRange getReturnTypeSourceRange() const
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
unsigned param_size() const
unsigned size() const
Determine the number of type parameters in this list.
ParmVarDecl - Represents a parameter to a function.
static void DiagnoseObjCImplementedDeprecations(Sema &S, NamedDecl *ND, SourceLocation ImplLoc, int select)
void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *CD, ObjCPropertyDecl *redeclaredProperty=nullptr, ObjCContainerDecl *lexicalDC=nullptr)
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods=None, ArrayRef< DeclGroupPtrTy > allTUVars=None)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
bool isScalarType() const
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList * > TypeParamLists, unsigned NumElts)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, const IdentifierLocPair *IdentList, unsigned NumElts, AttributeList *attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
ObjCMethodFamily
A family of Objective-C methods.
const CXXScopeSpec & getCXXScopeSpec() const
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
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.
ImplicitParamDecl * getCmdDecl() const
all_protocol_range all_referenced_protocols() const
void DeepCollectObjCIvars(const ObjCInterfaceDecl *OI, bool leafClass, SmallVectorImpl< const ObjCIvarDecl * > &Ivars) const
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)
void startDefinition()
Starts the definition of this Objective-C protocol.
static bool checkTypeParamListConsistency(Sema &S, ObjCTypeParamList *prevTypeParams, ObjCTypeParamList *newTypeParams, TypeParamListContext newContext)
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void CheckExtraCXXDefaultArguments(Declarator &D)
std::pair< NullabilityKind, bool > DiagNullabilityKind
llvm::BumpPtrAllocator BumpAlloc
SourceLocation getBeginLoc() const
Get the begin source location.
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, IdentifierInfo *ClassName, SmallVectorImpl< Decl * > &Decls)
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)
bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall)
void setMethod(ObjCMethodDecl *M)
SourceLocation getSelectorLoc(unsigned Index) const
Represents the results of name lookup.
ObjCMethodDecl * LookupImplementedMethodInGlobalPool(Selector Sel)
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
const LangOptions & getLangOpts() const
ObjCMethodDecl * getCurMethodDecl()
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void ActOnTypedefedProtocols(SmallVectorImpl< Decl * > &ProtocolRefs, IdentifierInfo *SuperName, SourceLocation SuperLoc)
SCS
storage-class-specifier
Decl * ActOnObjCContainerStartDefinition(Decl *IDecl)
void RemoveDecl(NamedDecl *D)
GlobalMethodPool MethodPool
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
void setExceptionVariable(bool EV)
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
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
Def If non-NULL, and the type refers to some kind of declaration that can be completed (such as a C s...
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)
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.
Represents an ObjC class declaration.
ObjCMethodDecl * getMethod() const
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
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, bool IncludeCXX11Attributes=true)
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
TyLocType push(QualType T)
ObjCProtocolDecl *const * iterator
field_iterator field_end() const
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
static Decl::ObjCDeclQualifier CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal)
static const Decl * getDefinition(const Decl *D)
static bool isAcceptableMethodMismatch(ObjCMethodDecl *chosen, ObjCMethodDecl *other)
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
DeclSpec & getMutableDeclSpec()
const ParmVarDecl *const * param_const_iterator
AvailabilityResult getAvailability(std::string *Message=nullptr) const
Determine the availability of the given declaration.
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.
std::string CurrentModule
The name of the current module.
llvm::SmallPtrSet< Selector, 8 > SelectorSet
bool inferObjCARCLifetime(ValueDecl *decl)
void SetRangeStart(SourceLocation Loc)
void AddAnyMethodToGlobalPool(Decl *D)
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.
ID
Defines the set of possible language-specific address spaces.
QualType getPointeeType() const
bool isUnarySelector() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
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)
unsigned getNumArgs() const
static Kind getNullabilityAttrKind(NullabilityKind kind)
bool isObjCClassType() const
bool CollectMultipleMethodsInGlobalPool(Selector Sel, SmallVectorImpl< ObjCMethodDecl * > &Methods, bool instance)
Returns instance or factory methods in global method pool for given selector. If no such method or on...
This file defines the classes used to store parsed information about declaration-specifiers and decla...
TypeResult ActOnTypeName(Scope *S, Declarator &D)
Expr * getBitWidth() const
void setInvalidDecl(bool Invalid=true)
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup. Asserts that one was found.
void setAtEndRange(SourceRange atEnd)
Defines the clang::Preprocessor interface.
void ActOnStartOfObjCMethodDef(Scope *S, Decl *D)
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)
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.
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)
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
Decl * ActOnStartClassImplementation(SourceLocation AtClassImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc)
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
const SourceRange & getRange() const
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type...
bool isDependentType() const
bool isInstanceMethod() const
clang::ObjCRuntime ObjCRuntime
bool isObjCQualifiedIdType() const
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)
DeclarationName getDeclName() const
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
void CollectInheritedProtocols(const Decl *CDecl, llvm::SmallPtrSet< ObjCProtocolDecl *, 8 > &Protocols)
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration. Return null if the results were absent...
SourceLocation getLocEnd() const LLVM_READONLY
SourceLocation getStorageClassSpecLoc() const
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)
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
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl)
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
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
static void findProtocolsWithExplicitImpls(const ObjCProtocolDecl *PDecl, ProtocolNameSet &PNS)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
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)
unsigned getBitWidthValue(const ASTContext &Ctx) const
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)
void setObjCDeclQualifier(ObjCDeclQualifier QV)
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
static bool objcModifiersConflict(Decl::ObjCDeclQualifier x, Decl::ObjCDeclQualifier y)
Determine whether two set of Objective-C declaration qualifiers conflict.
bool ObjCWarnForNoDesignatedInitChain
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)
std::unique_ptr< ProtocolNameSet > LazyProtocolNameSet
void DiagnoseUseOfUnimplementedSelectors()
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
static bool isObjCTypeSubstitutable(ASTContext &Context, const ObjCObjectPointerType *A, const ObjCObjectPointerType *B, bool rejectId)
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
const ObjCInterfaceDecl * getClassInterface() const
bool isPropertyAccessor() const
ObjCIvarDecl * GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, const ObjCPropertyDecl *&PDecl) const
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)
Represents one property declaration in an Objective-C interface.
std::string getAsString() const
Derive the full selector name (e.g. "foo:bar:") and return it as an std::string.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
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 SourceRange & getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
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.
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.
bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass)
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)
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
ObjCIvarDecl * getNextIvar()
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
ObjCDeclQualifier getObjCDeclQualifier() const
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)
const ObjCProtocolList & getReferencedProtocols() const
instmeth_range instance_methods() const
TSCS getThreadStorageClassSpec() const
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
ObjCCategoryImplDecl * getImplementation() const
void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD)
ObjCContainerKind getObjCContainerKind() const
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
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
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)
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.
static void CheckProtocolMethodDefs(Sema &S, SourceLocation ImpLoc, ObjCProtocolDecl *PDecl, bool &IncompleteImpl, const Sema::SelectorSet &InsMap, const Sema::SelectorSet &ClsMap, ObjCContainerDecl *CDecl, LazyProtocolNameSet &ProtocolsExplictImpl)
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool hasDefinition() const
Determine whether this protocol has a definition.
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
Selector getSelector() const
bool ObjCWarnForNoInitDelegation
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
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
DeclClass * getCorrectionDeclAs() const
bool hasMoreThanOneDecl() const
static bool HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param)
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
bool isObjCObjectType() const
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
SourceManager & getSourceManager() const
void setNext(ObjCMethodList *L)
ExternalSemaSource * getExternalSource() const
Decl::Kind getDeclKind() const
ObjCTypeParamList * getTypeParamList() const
void AddDecl(NamedDecl *D)
AddDecl - Link the decl to its shadowed decl chain.
void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool IncompleteImpl=false)
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
static __inline__ uint32_t uint32_t y
bool isObjCQualifiedIdType() const
static const TST TST_typename
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()
virtual void HandleTopLevelDeclInObjCContainer(DeclGroupRef D)
Handle the specified top-level declaration that occurred inside and ObjC container. The default implementation ignored them.
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)
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.
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
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Captures information about "declaration specifiers".
SourceLocation getIdentifierLoc() const
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
bool isObjCObjectPointerType() const
void SetRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, const ObjCMethodDecl *PrevMethod, MethodMatchStrategy strategy=MMS_strict)
bool CheckObjCDeclScope(Decl *D)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
bool CheckParmsForFunctionDef(ParmVarDecl *const *Param, ParmVarDecl *const *ParamEnd, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
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.
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc)
Return a DeclaratorChunk for a pointer.
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)
void ActOnObjCContainerFinishDefinition()
void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
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)
ObjCIvarDecl * all_declared_ivar_begin()
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)
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, bool ForCompare)
bool isNull() const
isNull - 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
void SetRangeEnd(SourceLocation Loc)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
void pushFullCopy(TypeLoc L)
void setType(QualType newType)
Optional< NullabilityKind > getNullability(const ASTContext &context) const
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP)
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
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)
ScalarTypeKind getScalarTypeKind() const
getScalarTypeKind - Given that this is a scalar type, classify it.
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
bool isIntegerType() const
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
Helper class that creates diagnostics with optional template instantiation stacks.
const DeclSpec & getDeclSpec() const
const ObjCProtocolList & getReferencedProtocols() const
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
Decl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc)
const ObjCInterfaceDecl * getSuperClass() const