clang 20.0.0git
|
#include "TypeLocBuilder.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTMutationListener.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/DelayedDiagnostic.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/SemaInternal.h"
#include "clang/Sema/SemaObjC.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "clang/AST/DeclNodes.inc"
Go to the source code of this file.
Macros | |
#define | OBJCCONTAINER(type, base) |
#define | ABSTRACT_DECL(expansion) |
#define | DECL(type, base) case Decl::type: |
Typedefs | |
typedef llvm::DenseSet< IdentifierInfo * > | ProtocolNameSet |
FIXME: Type hierarchies in Objective-C can be deep. | |
typedef std::unique_ptr< ProtocolNameSet > | LazyProtocolNameSet |
Functions | |
static bool | diagnoseNoescape (const ParmVarDecl *NewD, const ParmVarDecl *OldD, Sema &S) |
Issue a warning if the parameter of the overridden method is non-escaping but the parameter of the overriding method is not. | |
static void | diagnoseNoescape (const ParmVarDecl *NewD, const ParmVarDecl *OldD, const ObjCCategoryDecl *CD, const ObjCProtocolDecl *PD, Sema &S) |
Produce additional diagnostics if a category conforms to a protocol that defines a method taking a non-escaping parameter. | |
static void | DiagnoseObjCImplementedDeprecations (Sema &S, const NamedDecl *ND, SourceLocation ImplLoc) |
static bool | HasExplicitOwnershipAttr (Sema &S, ParmVarDecl *Param) |
HasExplicitOwnershipAttr - returns true when pointer to ObjC pointer has explicit ownership attribute; false otherwise. | |
static void | diagnoseUseOfProtocols (Sema &TheSema, ObjCContainerDecl *CD, ObjCProtocolDecl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs) |
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 and an @interface or between an @class and an @interface. | |
static bool | NestedProtocolHasNoDefinition (ObjCProtocolDecl *PDecl, ObjCProtocolDecl *&UndefinedProtocol) |
static bool | shouldWarnUndefinedMethod (const ObjCMethodDecl *M) |
static void | WarnUndefinedMethod (Sema &S, ObjCImplDecl *Impl, ObjCMethodDecl *method, bool &IncompleteImpl, unsigned DiagID, NamedDecl *NeededFor=nullptr) |
static bool | isObjCTypeSubstitutable (ASTContext &Context, const ObjCObjectPointerType *A, const ObjCObjectPointerType *B, bool rejectId) |
Determines if type B can be substituted for type A. | |
static SourceRange | getTypeRange (TypeSourceInfo *TSI) |
static bool | objcModifiersConflict (Decl::ObjCDeclQualifier x, Decl::ObjCDeclQualifier y) |
Determine whether two set of Objective-C declaration qualifiers conflict. | |
static bool | CheckMethodOverrideReturn (Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn) |
static bool | CheckMethodOverrideParam (Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, ParmVarDecl *ImplVar, ParmVarDecl *IfaceVar, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn) |
static bool | checkMethodFamilyMismatch (Sema &S, ObjCMethodDecl *impl, ObjCMethodDecl *decl) |
In ARC, check whether the conventional meanings of the two methods match. | |
static void | findProtocolsWithExplicitImpls (const ObjCProtocolDecl *PDecl, ProtocolNameSet &PNS) |
static void | findProtocolsWithExplicitImpls (const ObjCInterfaceDecl *Super, ProtocolNameSet &PNS) |
Recursively populates a set with all conformed protocols in a class hierarchy that have the 'objc_protocol_requires_explicit_implementation' attribute. | |
static void | CheckProtocolMethodDefs (Sema &S, ObjCImplDecl *Impl, ObjCProtocolDecl *PDecl, bool &IncompleteImpl, const SemaObjC::SelectorSet &InsMap, const SemaObjC::SelectorSet &ClsMap, ObjCContainerDecl *CDecl, LazyProtocolNameSet &ProtocolsExplictImpl) |
CheckProtocolMethodDefs - This routine checks unimplemented methods Declared in protocol, and those referenced by it. | |
static bool | tryMatchRecordTypes (ASTContext &Context, SemaObjC::MethodMatchStrategy strategy, const Type *left, const Type *right) |
static bool | matchTypes (ASTContext &Context, SemaObjC::MethodMatchStrategy strategy, QualType leftQT, QualType rightQT) |
static bool | isMethodContextSameForKindofLookup (ObjCMethodDecl *Method, ObjCMethodDecl *MethodInList) |
static bool | isAcceptableMethodMismatch (ObjCMethodDecl *chosen, ObjCMethodDecl *other) |
Determines if this is an "acceptable" loose mismatch in the global method pool. | |
static bool | FilterMethodsByTypeBound (ObjCMethodDecl *Method, const ObjCObjectType *TypeBound) |
Return true if the given method is wthin the type bound. | |
static void | HelperSelectorsForTypoCorrection (SmallVectorImpl< const ObjCMethodDecl * > &BestMethod, StringRef Typo, const ObjCMethodDecl *Method) |
static bool | HelperIsMethodInObjCType (Sema &S, Selector Sel, QualType ObjectType) |
static void | DiagnoseWeakIvars (Sema &S, ObjCImplementationDecl *ID) |
Diagnose attempts to define ARC-__weak ivars when __weak is disabled. | |
static void | DiagnoseRetainableFlexibleArrayMember (Sema &S, ObjCInterfaceDecl *ID) |
Diagnose attempts to use flexible array member with retainable object type. | |
static bool | IsVariableSizedType (QualType T) |
static void | DiagnoseVariableSizedIvars (Sema &S, ObjCContainerDecl *OCD) |
static void | DiagnoseCategoryDirectMembersProtocolConformance (Sema &S, ObjCProtocolDecl *PDecl, ObjCCategoryDecl *CDecl) |
static void | DiagnoseCategoryDirectMembersProtocolConformance (Sema &S, ObjCCategoryDecl *CDecl, const llvm::iterator_range< ObjCProtocolList::iterator > &Protocols) |
static Decl::ObjCDeclQualifier | CvtQTToAstBitMask (ObjCDeclSpec::ObjCDeclQualifier PQTVal) |
CvtQTToAstBitMask - utility routine to produce an AST bitmask for objective-c's type qualifier from the parser version of the same info. | |
static SemaObjC::ResultTypeCompatibilityKind | CheckRelatedResultTypeCompatibility (Sema &S, ObjCMethodDecl *Method, ObjCInterfaceDecl *CurrentClass) |
Check whether the declared result type of the given Objective-C method declaration is compatible with the method's class. | |
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 redeclared entity. | |
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 the corresponding method in the @implementation (for a class or category). | |
static void | checkObjCMethodX86VectorTypes (Sema &SemaRef, const ObjCMethodDecl *Method) |
Verify that the method parameters/return value have types that are supported by the x86 target. | |
static void | mergeObjCDirectMembers (Sema &S, Decl *CD, ObjCMethodDecl *Method) |
static void | checkObjCDirectMethodClashes (Sema &S, ObjCInterfaceDecl *IDecl, ObjCMethodDecl *Method, ObjCImplDecl *ImpDecl=nullptr) |
static ObjCIvarDecl::AccessControl | TranslateIvarVisibility (tok::ObjCKeywordKind ivarVisibility) |
TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value. | |
#define ABSTRACT_DECL | ( | expansion | ) |
#define DECL | ( | type, | |
base | |||
) | case Decl::type: |
#define OBJCCONTAINER | ( | type, | |
base | |||
) |
typedef std::unique_ptr<ProtocolNameSet> LazyProtocolNameSet |
Definition at line 2684 of file SemaDeclObjC.cpp.
typedef llvm::DenseSet<IdentifierInfo*> ProtocolNameSet |
FIXME: Type hierarchies in Objective-C can be deep.
We could most likely improve the efficiency of selector lookups and type checking by associating with each protocol / interface / category the flattened instance tables. If we used an immutable set to keep the table then it wouldn't add significant memory cost and it would be handy for lookups.
Definition at line 2683 of file SemaDeclObjC.cpp.
|
static |
In ARC, check whether the conventional meanings of the two methods match.
If they don't, it's a hard error.
Definition at line 2516 of file SemaDeclObjC.cpp.
References clang::ast_matchers::decl, clang::SemaBase::Diag(), clang::Decl::getLocation(), clang::ObjCMethodDecl::getMethodFamily(), clang::ObjCMethodDecl::getReturnType(), int, clang::Decl::isInvalidDecl(), clang::Type::isObjCObjectPointerType(), clang::OMF_alloc, clang::OMF_autorelease, clang::OMF_copy, clang::OMF_dealloc, clang::OMF_finalize, clang::OMF_init, clang::OMF_initialize, clang::OMF_mutableCopy, clang::OMF_new, clang::OMF_None, clang::OMF_performSelector, clang::OMF_release, clang::OMF_retain, clang::OMF_retainCount, and clang::OMF_self.
Referenced by clang::SemaObjC::WarnConflictingTypedMethods().
|
static |
Definition at line 2433 of file SemaDeclObjC.cpp.
References clang::Sema::Context, clang::SemaBase::Diag(), clang::Type::getAs(), clang::Decl::getDeclContext(), clang::NamedDecl::getDeclName(), clang::Decl::getLocation(), clang::Type::getNullability(), clang::ParmVarDecl::getObjCDeclQualifier(), clang::ValueDecl::getType(), getTypeRange(), clang::DeclaratorDecl::getTypeSourceInfo(), clang::ASTContext::hasSameNullabilityTypeQualifier(), clang::ASTContext::hasSameUnqualifiedType(), isObjCTypeSubstitutable(), clang::Decl::OBJC_TQ_CSNullability, and objcModifiersConflict().
Referenced by clang::SemaObjC::CheckConflictingOverridingMethod(), clang::SemaObjC::WarnConflictingTypedMethods(), and clang::SemaObjC::WarnExactTypedMethods().
|
static |
Definition at line 2353 of file SemaDeclObjC.cpp.
References clang::Sema::Context, clang::SemaBase::Diag(), clang::Type::getAs(), clang::Decl::getDeclContext(), clang::NamedDecl::getDeclName(), clang::Decl::getLocation(), clang::Type::getNullability(), clang::ObjCMethodDecl::getObjCDeclQualifier(), clang::ObjCMethodDecl::getReturnType(), clang::ObjCMethodDecl::getReturnTypeSourceRange(), clang::ASTContext::hasSameNullabilityTypeQualifier(), clang::ASTContext::hasSameUnqualifiedType(), isObjCTypeSubstitutable(), clang::Decl::OBJC_TQ_CSNullability, and objcModifiersConflict().
Referenced by clang::SemaObjC::CheckConflictingOverridingMethod(), clang::SemaObjC::WarnConflictingTypedMethods(), and clang::SemaObjC::WarnExactTypedMethods().
|
static |
Definition at line 4680 of file SemaDeclObjC.cpp.
References clang::SemaBase::Diag(), clang::NamedDecl::getDeclName(), clang::ObjCInterfaceDecl::getImplementation(), clang::Decl::getLocation(), clang::ObjCContainerDecl::getMethod(), clang::ObjCMethodDecl::getSelector(), clang::ObjCMethodDecl::isDirectMethod(), clang::ObjCMethodDecl::isInstanceMethod(), and clang::ObjCInterfaceDecl::visible_categories().
Referenced by clang::SemaObjC::ActOnMethodDeclaration().
|
static |
Verify that the method parameters/return value have types that are supported by the x86 target.
Definition at line 4631 of file SemaDeclObjC.cpp.
References clang::SemaBase::Diag(), clang::Sema::getASTContext(), clang::SourceRange::getBegin(), clang::TargetInfo::getPlatformMinVersion(), clang::ObjCMethodDecl::getReturnType(), clang::ObjCMethodDecl::getReturnTypeSourceRange(), clang::ASTContext::getTargetInfo(), clang::TargetInfo::getTriple(), clang::SourceLocation::isInvalid(), clang::Type::isVectorType(), Loc, P, clang::ObjCMethodDecl::parameters(), and clang::T.
Referenced by clang::SemaObjC::ActOnMethodDeclaration().
|
static |
CheckProtocolMethodDefs - This routine checks unimplemented methods Declared in protocol, and those referenced by it.
Definition at line 2710 of file SemaDeclObjC.cpp.
References clang::C, CheckProtocolMethodDefs(), clang::ObjCContainerDecl::class_methods(), clang::Sema::Context, DIAG, clang::Sema::Diags, findProtocolsWithExplicitImpls(), clang::IdentifierTable::get(), clang::ObjCProtocolDecl::getDefinition(), clang::NamedDecl::getIdentifier(), clang::Sema::getLangOpts(), clang::Decl::getLocation(), clang::SelectorTable::getSelector(), clang::ObjCInterfaceDecl::getSuperClass(), clang::Decl::hasAttr(), clang::ASTContext::Idents, clang::ObjCContainerDecl::instance_methods(), clang::DiagnosticsEngine::isIgnored(), clang::ObjCRuntime::isNeXTFamily(), clang::ObjCProtocolDecl::isThisDeclarationADefinition(), clang::ObjCInterfaceDecl::lookupInheritedClass(), clang::ObjCInterfaceDecl::lookupMethod(), clang::LangOptions::ObjCRuntime, clang::Optional, clang::ObjCProtocolDecl::protocols(), clang::ASTContext::Selectors, and WarnUndefinedMethod().
Referenced by CheckProtocolMethodDefs(), and clang::SemaObjC::ImplMethodsVsClassMethods().
|
static |
Check whether the declared result type of the given Objective-C method declaration is compatible with the method's class.
Definition at line 4246 of file SemaDeclObjC.cpp.
References clang::declaresSameEntity(), clang::Type::getAs(), clang::ObjCMethodDecl::getReturnType(), clang::SemaObjC::RTC_Compatible, clang::SemaObjC::RTC_Incompatible, and clang::SemaObjC::RTC_Unknown.
Referenced by clang::SemaObjC::ActOnMethodDeclaration().
|
static |
Check consistency between two Objective-C type parameter lists, e.g., between a category/extension and an @interface or between an @class and an @interface.
Definition at line 828 of file SemaDeclObjC.cpp.
References clang::ASTContext::adjustObjCTypeParamBoundType(), clang::ObjCTypeParamList::back(), clang::ObjCTypeParamList::begin(), clang::Sema::Context, clang::Contravariant, clang::Covariant, clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateRemoval(), clang::FixItHint::CreateReplacement(), clang::SemaBase::Diag(), clang::QualType::getAsString(), clang::SourceRange::getBegin(), clang::TypeDecl::getBeginLoc(), clang::Decl::getDeclContext(), clang::NamedDecl::getDeclName(), clang::Decl::getEndLoc(), clang::Decl::getLocation(), clang::Sema::getLocForEndOfToken(), clang::ASTContext::getPrintingPolicy(), clang::TypeLoc::getSourceRange(), clang::TypeSourceInfo::getTypeLoc(), clang::TypedefNameDecl::getTypeSourceInfo(), clang::TypedefNameDecl::getUnderlyingType(), clang::ObjCTypeParamDecl::getVariance(), clang::ObjCTypeParamDecl::getVarianceLoc(), clang::ObjCTypeParamDecl::hasExplicitBound(), clang::ASTContext::hasSameType(), clang::Invariant, clang::SourceLocation::isInvalid(), clang::ObjCTypeParamDecl::setVariance(), and clang::ObjCTypeParamList::size().
Referenced by clang::SemaObjC::ActOnForwardClassDeclaration(), clang::SemaObjC::ActOnStartCategoryInterface(), and clang::SemaObjC::ActOnStartClassInterface().
|
static |
CvtQTToAstBitMask - utility routine to produce an AST bitmask for objective-c's type qualifier from the parser version of the same info.
Definition at line 4238 of file SemaDeclObjC.cpp.
Referenced by clang::SemaObjC::ActOnMethodDeclaration().
|
static |
Definition at line 3936 of file SemaDeclObjC.cpp.
References DiagnoseCategoryDirectMembersProtocolConformance().
|
static |
Definition at line 3943 of file SemaDeclObjC.cpp.
References clang::SemaBase::Diag(), DiagnoseCategoryDirectMembersProtocolConformance(), clang::ObjCCategoryDecl::getClassInterface(), clang::ObjCProtocolDecl::getDefinition(), clang::Decl::getLocation(), clang::ObjCCategoryDecl::IsClassExtension(), clang::ObjCProtocolDecl::isThisDeclarationADefinition(), clang::ObjCContainerDecl::methods(), clang::OBJC_PR_query_class, clang::OBJC_PR_query_instance, clang::ObjCContainerDecl::properties(), and clang::ObjCProtocolDecl::protocols().
Referenced by clang::SemaObjC::ActOnAtEnd(), and DiagnoseCategoryDirectMembersProtocolConformance().
|
static |
Produce additional diagnostics if a category conforms to a protocol that defines a method taking a non-escaping parameter.
Definition at line 132 of file SemaDeclObjC.cpp.
References clang::SemaBase::Diag(), diagnoseNoescape(), clang::Decl::getDeclContext(), clang::Decl::getLocation(), and clang::ObjCCategoryDecl::IsClassExtension().
|
static |
Issue a warning if the parameter of the overridden method is non-escaping but the parameter of the overriding method is not.
Definition at line 119 of file SemaDeclObjC.cpp.
References clang::SemaBase::Diag(), clang::Decl::getLocation(), and clang::Decl::hasAttr().
Referenced by clang::SemaObjC::ActOnMethodDeclaration(), clang::SemaObjC::CheckObjCMethodOverride(), and diagnoseNoescape().
|
static |
Definition at line 289 of file SemaDeclObjC.cpp.
References clang::AR_Deprecated, clang::AR_Unavailable, clang::Sema::Context, clang::SemaBase::Diag(), clang::Decl::getAvailability(), clang::NamedDecl::getDeclName(), clang::Decl::getLocation(), clang::TargetInfo::getPlatformName(), and clang::ASTContext::getTargetInfo().
Referenced by clang::SemaObjC::ActOnStartCategoryImplementation(), clang::SemaObjC::ActOnStartClassImplementation(), and clang::SemaObjC::ActOnStartOfObjCMethodDef().
|
static |
Diagnose attempts to use flexible array member with retainable object type.
Definition at line 3804 of file SemaDeclObjC.cpp.
References clang::SemaBase::Diag(), clang::Sema::getLangOpts(), clang::QualType::getObjCLifetime(), clang::Type::isIncompleteArrayType(), clang::Type::isObjCLifetimeType(), and clang::Qualifiers::OCL_ExplicitNone.
Referenced by clang::SemaObjC::ActOnAtEnd().
|
static |
Definition at line 537 of file SemaDeclObjC.cpp.
References clang::Sema::DiagnoseUseOfDecl().
Referenced by clang::SemaObjC::ActOnStartCategoryInterface(), clang::SemaObjC::ActOnStartClassInterface(), and clang::SemaObjC::ActOnStartProtocolInterface().
|
static |
Definition at line 3850 of file SemaDeclObjC.cpp.
References clang::ObjCInterfaceDecl::all_declared_ivar_begin(), clang::Class, clang::SemaBase::Diag(), clang::Type::getAs(), clang::NamedDecl::getDeclName(), clang::Decl::getLocation(), clang::ObjCIvarDecl::getNextIvar(), clang::ObjCInterfaceDecl::getSuperClass(), clang::ValueDecl::getType(), clang::Type::isIncompleteArrayType(), IsVariableSizedType(), clang::ObjCInterfaceDecl::ivar_begin(), clang::ObjCInterfaceDecl::ivar_empty(), clang::ObjCInterfaceDecl::ivar_size(), and clang::ObjCInterfaceDecl::ivars().
Referenced by clang::SemaObjC::ActOnAtEnd().
|
static |
Diagnose attempts to define ARC-__weak ivars when __weak is disabled.
Definition at line 3787 of file SemaDeclObjC.cpp.
References clang::SemaBase::Diag(), clang::Sema::getLangOpts(), and clang::Qualifiers::OCL_Weak.
Referenced by clang::SemaObjC::ActOnAtEnd().
|
static |
Return true if the given method is wthin the type bound.
Definition at line 3480 of file SemaDeclObjC.cpp.
References clang::ObjCMethodDecl::getClassInterface(), clang::Decl::getDeclContext(), clang::ObjCObjectType::getInterface(), and clang::ObjCObjectType::isObjCId().
Referenced by clang::SemaObjC::CollectMultipleMethodsInGlobalPool().
|
static |
Recursively populates a set with all conformed protocols in a class hierarchy that have the 'objc_protocol_requires_explicit_implementation' attribute.
Definition at line 2697 of file SemaDeclObjC.cpp.
References clang::ObjCInterfaceDecl::all_referenced_protocols(), findProtocolsWithExplicitImpls(), and clang::ObjCInterfaceDecl::getSuperClass().
|
static |
Definition at line 2686 of file SemaDeclObjC.cpp.
References findProtocolsWithExplicitImpls(), clang::NamedDecl::getIdentifier(), clang::Decl::hasAttr(), and clang::ObjCProtocolDecl::protocols().
Referenced by CheckProtocolMethodDefs(), and findProtocolsWithExplicitImpls().
|
static |
Definition at line 2342 of file SemaDeclObjC.cpp.
References clang::TypeLoc::getSourceRange(), and clang::TypeSourceInfo::getTypeLoc().
Referenced by CheckMethodOverrideParam().
|
static |
HasExplicitOwnershipAttr - returns true when pointer to ObjC pointer has explicit ownership attribute; false otherwise.
Definition at line 351 of file SemaDeclObjC.cpp.
References clang::Type::getAs(), clang::Type::getPointeeType(), clang::ValueDecl::getType(), and clang::T.
Referenced by clang::SemaObjC::ActOnStartOfObjCMethodDef().
Definition at line 3697 of file SemaDeclObjC.cpp.
References clang::QualType::isNull(), clang::SemaObjC::LookupMethodInObjectType(), and clang::Sema::ObjC().
Referenced by clang::SemaObjC::SelectorsForTypoCorrection().
|
static |
Definition at line 3675 of file SemaDeclObjC.cpp.
References abs(), clang::Selector::getAsString(), and clang::ObjCMethodDecl::getSelector().
Referenced by clang::SemaObjC::SelectorsForTypoCorrection().
|
static |
Determines if this is an "acceptable" loose mismatch in the global method pool.
This exists mostly as a hack to get around certain global mismatches which we can't afford to make warnings / errors. Really, what we want is a way to take a method out of the global method pool.
Definition at line 3462 of file SemaDeclObjC.cpp.
References clang::Selector::getNameForSlot(), clang::ObjCMethodDecl::getReturnType(), clang::ObjCMethodDecl::getSelector(), clang::ObjCMethodDecl::isDirectMethod(), clang::ObjCMethodDecl::isInstanceMethod(), clang::Type::isIntegerType(), and clang::Selector::isUnarySelector().
Referenced by clang::SemaObjC::DiagnoseMultipleMethodInGlobalPool().
|
static |
Definition at line 3299 of file SemaDeclObjC.cpp.
References clang::ObjCMethodDecl::getClassInterface(), and clang::Decl::getDeclContext().
Referenced by clang::SemaObjC::addMethodToGlobalList().
|
static |
Determines if type B can be substituted for type A.
Returns true if we can guarantee that anything that the user will do to an object of type A can also be done to an object of type B. This is trivially true if the two types are the same, or if B is a subclass of A. It becomes more complex in cases where protocols are involved.
Object types in Objective-C describe the minimum requirements for an object, rather than providing a complete description of a type. For example, if A is a subclass of B, then B* may refer to an instance of A. The principle of substitutability means that we may use an instance of A anywhere that we may use an instance of B - it will implement all of the ivars of B and all of the methods of B.
This substitutability is important when type checking methods, because the implementation may have stricter type definitions than the interface. The interface specifies minimum requirements, but the implementation may have more accurate ones. For example, a method may privately accept instances of B, but only publish that it accepts instances of A. Any object passed to it will be type checked against B, and so will implicitly by a valid A*. Similarly, a method may return a subclass of the class that it is declared as returning.
This is most important when considering subclassing. A method in a subclass must accept any object as an argument that its superclass's implementation accepts. It may, however, accept a more general type without breaking substitutability (i.e. you can still use the subclass anywhere that you can use the superclass, but not vice versa). The converse requirement applies to return types: the return type for a subclass method must be a valid object of the kind that the superclass advertises, but it may be specified more accurately. This avoids the need for explicit down-casting by callers.
Note: This is a stricter requirement than for assignment.
Definition at line 2310 of file SemaDeclObjC.cpp.
References clang::ASTContext::canAssignObjCInterfaces(), clang::ObjCObjectPointerType::isObjCIdType(), clang::ObjCObjectPointerType::isObjCQualifiedIdType(), and clang::ASTContext::ObjCQualifiedIdTypesAreCompatible().
Referenced by CheckMethodOverrideParam(), and CheckMethodOverrideReturn().
Definition at line 3843 of file SemaDeclObjC.cpp.
References clang::Type::getAs(), clang::Type::isIncompleteArrayType(), and clang::T.
Referenced by DiagnoseVariableSizedIvars().
|
static |
Definition at line 3161 of file SemaDeclObjC.cpp.
References clang::TypeInfo::Align, clang::ASTContext::getCanonicalType(), clang::Type::getScalarTypeKind(), clang::ASTContext::getTypeInfo(), clang::CanQual< T >::getTypePtr(), clang::CanQual< T >::getUnqualifiedType(), clang::Type::isIncompleteType(), clang::Type::isScalarType(), clang::SemaObjC::MMS_strict, clang::Type::STK_BlockPointer, clang::Type::STK_Bool, clang::Type::STK_CPointer, clang::Type::STK_Integral, clang::Type::STK_ObjCObjectPointer, tryMatchRecordTypes(), and clang::TypeInfo::Width.
Referenced by clang::SemaObjC::MatchTwoMethodDeclarations(), and tryMatchRecordTypes().
|
static |
Merge information from the declaration of a method in the @interface (or a category/extension) into the corresponding method in the @implementation (for a class or category).
Definition at line 4588 of file SemaDeclObjC.cpp.
References clang::Decl::addAttr(), clang::Sema::Context, clang::SourceRange::getBegin(), clang::Decl::getLocation(), clang::ParmVarDecl::getObjCDeclQualifier(), clang::ObjCMethodDecl::getObjCDeclQualifier(), clang::ObjCMethodDecl::getReturnType(), clang::ObjCMethodDecl::getReturnTypeSourceRange(), clang::ValueDecl::getType(), clang::Decl::hasAttr(), mergeTypeNullabilityForRedecl(), clang::Decl::OBJC_TQ_CSNullability, clang::ObjCMethodDecl::param_begin(), clang::ObjCMethodDecl::param_size(), clang::ObjCMethodDecl::setReturnType(), and clang::ValueDecl::setType().
Referenced by clang::SemaObjC::ActOnMethodDeclaration().
|
static |
Definition at line 4672 of file SemaDeclObjC.cpp.
References clang::Decl::addAttr(), clang::Sema::Context, clang::Decl::getLocation(), clang::Decl::hasAttr(), and clang::ObjCMethodDecl::isDirectMethod().
Referenced by clang::SemaObjC::ActOnMethodDeclaration().
|
static |
Merge type nullability from for a redeclaration of the same entity, producing the updated type of the redeclared entity.
Definition at line 4548 of file SemaDeclObjC.cpp.
References clang::Sema::Context, clang::SemaBase::Diag(), clang::ASTContext::getAttributedType(), clang::Type::getNullability(), clang::AttributedType::getNullabilityAttrKind(), and clang::ast_matchers::type.
Referenced by mergeInterfaceMethodToImpl().
|
static |
Definition at line 1292 of file SemaDeclObjC.cpp.
References clang::ObjCProtocolDecl::getDefinition(), clang::ObjCProtocolDecl::hasDefinition(), clang::Decl::isUnconditionallyVisible(), NestedProtocolHasNoDefinition(), and clang::ObjCProtocolDecl::protocols().
Referenced by clang::SemaObjC::actOnObjCTypeArgsOrProtocolQualifiers(), clang::SemaObjC::FindProtocolDeclaration(), and NestedProtocolHasNoDefinition().
|
static |
Determine whether two set of Objective-C declaration qualifiers conflict.
Definition at line 2347 of file SemaDeclObjC.cpp.
References clang::Decl::OBJC_TQ_CSNullability.
Referenced by CheckMethodOverrideParam(), and CheckMethodOverrideReturn().
|
static |
Definition at line 2237 of file SemaDeclObjC.cpp.
References clang::AR_Unavailable, and clang::Decl::getAvailability().
Referenced by WarnUndefinedMethod().
|
static |
TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value.
Definition at line 5556 of file SemaDeclObjC.cpp.
References clang::ObjCIvarDecl::Package, clang::ObjCIvarDecl::Private, clang::ObjCIvarDecl::Protected, and clang::ObjCIvarDecl::Public.
Referenced by clang::SemaObjC::ActOnIvar().
|
static |
Definition at line 3220 of file SemaDeclObjC.cpp.
References clang::TypeInfo::Align, clang::RecordDecl::field_begin(), clang::RecordDecl::field_end(), clang::ASTContext::getTypeInfo(), clang::TagDecl::isUnion(), matchTypes(), and clang::TypeInfo::Width.
Referenced by matchTypes().
|
static |
Definition at line 2242 of file SemaDeclObjC.cpp.
References clang::FixItHint::CreateInsertion(), clang::SemaBase::Diag(), clang::Decl::getASTContext(), clang::ObjCContainerDecl::getAtEndRange(), clang::SourceRange::getBegin(), clang::ObjCMethodDecl::getBeginLoc(), clang::Decl::getLocation(), clang::ASTContext::getPrintingPolicy(), clang::SourceLocation::isValid(), Loc, and shouldWarnUndefinedMethod().
Referenced by CheckProtocolMethodDefs(), and clang::SemaObjC::MatchAllMethodDeclarations().