#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"
usingnamespaceclang;
bool SemaObjC::checkInitMethod(ObjCMethodDecl *method,
QualType receiverTypeIfCall) { … }
static bool diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD,
Sema &S) { … }
static void diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD,
const ObjCCategoryDecl *CD,
const ObjCProtocolDecl *PD, Sema &S) { … }
void SemaObjC::CheckObjCMethodOverride(ObjCMethodDecl *NewMethod,
const ObjCMethodDecl *Overridden) { … }
bool SemaObjC::CheckARCMethodDecl(ObjCMethodDecl *method) { … }
static void DiagnoseObjCImplementedDeprecations(Sema &S, const NamedDecl *ND,
SourceLocation ImplLoc) { … }
void SemaObjC::AddAnyMethodToGlobalPool(Decl *D) { … }
static bool
HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param) { … }
void SemaObjC::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) { … }
namespace {
class ObjCInterfaceValidatorCCC final : public CorrectionCandidateCallback { … };
}
static void diagnoseUseOfProtocols(Sema &TheSema,
ObjCContainerDecl *CD,
ObjCProtocolDecl *const *ProtoRefs,
unsigned NumProtoRefs,
const SourceLocation *ProtoLocs) { … }
void SemaObjC::ActOnSuperClassOfClassInterface(
Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl,
IdentifierInfo *ClassName, SourceLocation ClassLoc,
IdentifierInfo *SuperName, SourceLocation SuperLoc,
ArrayRef<ParsedType> SuperTypeArgs, SourceRange SuperTypeArgsRange) { … }
DeclResult SemaObjC::actOnObjCTypeParam(
Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc,
unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc,
SourceLocation colonLoc, ParsedType parsedTypeBound) { … }
ObjCTypeParamList *
SemaObjC::actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc,
ArrayRef<Decl *> typeParamsIn,
SourceLocation rAngleLoc) { … }
void SemaObjC::popObjCTypeParamList(Scope *S,
ObjCTypeParamList *typeParamList) { … }
namespace {
enum class TypeParamListContext { … };
}
static bool checkTypeParamListConsistency(Sema &S,
ObjCTypeParamList *prevTypeParams,
ObjCTypeParamList *newTypeParams,
TypeParamListContext newContext) { … }
ObjCInterfaceDecl *SemaObjC::ActOnStartClassInterface(
Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName,
SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
IdentifierInfo *SuperName, SourceLocation SuperLoc,
ArrayRef<ParsedType> SuperTypeArgs, SourceRange SuperTypeArgsRange,
Decl *const *ProtoRefs, unsigned NumProtoRefs,
const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody) { … }
void SemaObjC::ActOnTypedefedProtocols(
SmallVectorImpl<Decl *> &ProtocolRefs,
SmallVectorImpl<SourceLocation> &ProtocolLocs, IdentifierInfo *SuperName,
SourceLocation SuperLoc) { … }
Decl *SemaObjC::ActOnCompatibilityAlias(SourceLocation AtLoc,
IdentifierInfo *AliasName,
SourceLocation AliasLocation,
IdentifierInfo *ClassName,
SourceLocation ClassLocation) { … }
bool SemaObjC::CheckForwardProtocolDeclarationForCircularDependency(
IdentifierInfo *PName, SourceLocation &Ploc, SourceLocation PrevLoc,
const ObjCList<ObjCProtocolDecl> &PList) { … }
ObjCProtocolDecl *SemaObjC::ActOnStartProtocolInterface(
SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName,
SourceLocation ProtocolLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs,
const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody) { … }
static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl,
ObjCProtocolDecl *&UndefinedProtocol) { … }
void SemaObjC::FindProtocolDeclaration(bool WarnOnDeclarations,
bool ForObjCContainer,
ArrayRef<IdentifierLocPair> ProtocolId,
SmallVectorImpl<Decl *> &Protocols) { … }
namespace {
class ObjCTypeArgOrProtocolValidatorCCC final
: public CorrectionCandidateCallback { … };
}
void SemaObjC::DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId,
SourceLocation ProtocolLoc,
IdentifierInfo *TypeArgId,
SourceLocation TypeArgLoc,
bool SelectProtocolFirst) { … }
void SemaObjC::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) { … }
void SemaObjC::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
ObjCInterfaceDecl *ID) { … }
SemaObjC::DeclGroupPtrTy SemaObjC::ActOnForwardProtocolDeclaration(
SourceLocation AtProtocolLoc, ArrayRef<IdentifierLocPair> IdentList,
const ParsedAttributesView &attrList) { … }
ObjCCategoryDecl *SemaObjC::ActOnStartCategoryInterface(
SourceLocation AtInterfaceLoc, const IdentifierInfo *ClassName,
SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
const IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
Decl *const *ProtoRefs, unsigned NumProtoRefs,
const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
const ParsedAttributesView &AttrList) { … }
ObjCCategoryImplDecl *SemaObjC::ActOnStartCategoryImplementation(
SourceLocation AtCatImplLoc, const IdentifierInfo *ClassName,
SourceLocation ClassLoc, const IdentifierInfo *CatName,
SourceLocation CatLoc, const ParsedAttributesView &Attrs) { … }
ObjCImplementationDecl *SemaObjC::ActOnStartClassImplementation(
SourceLocation AtClassImplLoc, const IdentifierInfo *ClassName,
SourceLocation ClassLoc, const IdentifierInfo *SuperClassname,
SourceLocation SuperClassLoc, const ParsedAttributesView &Attrs) { … }
SemaObjC::DeclGroupPtrTy
SemaObjC::ActOnFinishObjCImplementation(Decl *ObjCImpDecl,
ArrayRef<Decl *> Decls) { … }
void SemaObjC::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
ObjCIvarDecl **ivars, unsigned numIvars,
SourceLocation RBrace) { … }
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) { … }
static SourceRange getTypeRange(TypeSourceInfo *TSI) { … }
static bool objcModifiersConflict(Decl::ObjCDeclQualifier x,
Decl::ObjCDeclQualifier y) { … }
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) { … }
void SemaObjC::WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethodDecl,
ObjCMethodDecl *MethodDecl,
bool IsProtocolMethodDecl) { … }
void SemaObjC::CheckConflictingOverridingMethod(ObjCMethodDecl *Method,
ObjCMethodDecl *Overridden,
bool IsProtocolMethodDecl) { … }
void SemaObjC::WarnExactTypedMethods(ObjCMethodDecl *ImpMethodDecl,
ObjCMethodDecl *MethodDecl,
bool IsProtocolMethodDecl) { … }
ProtocolNameSet;
LazyProtocolNameSet;
static void findProtocolsWithExplicitImpls(const ObjCProtocolDecl *PDecl,
ProtocolNameSet &PNS) { … }
static void findProtocolsWithExplicitImpls(const ObjCInterfaceDecl *Super,
ProtocolNameSet &PNS) { … }
static void CheckProtocolMethodDefs(
Sema &S, ObjCImplDecl *Impl, ObjCProtocolDecl *PDecl, bool &IncompleteImpl,
const SemaObjC::SelectorSet &InsMap, const SemaObjC::SelectorSet &ClsMap,
ObjCContainerDecl *CDecl, LazyProtocolNameSet &ProtocolsExplictImpl) { … }
void SemaObjC::MatchAllMethodDeclarations(
const SelectorSet &InsMap, const SelectorSet &ClsMap,
SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl,
ObjCContainerDecl *CDecl, bool &IncompleteImpl, bool ImmediateClass,
bool WarnCategoryMethodImpl) { … }
void SemaObjC::CheckCategoryVsClassMethodMatches(
ObjCCategoryImplDecl *CatIMPDecl) { … }
void SemaObjC::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl *IMPDecl,
ObjCContainerDecl *CDecl,
bool IncompleteImpl) { … }
SemaObjC::DeclGroupPtrTy SemaObjC::ActOnForwardClassDeclaration(
SourceLocation AtClassLoc, IdentifierInfo **IdentList,
SourceLocation *IdentLocs, ArrayRef<ObjCTypeParamList *> TypeParamLists,
unsigned NumElts) { … }
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 tryMatchRecordTypes(ASTContext &Context,
SemaObjC::MethodMatchStrategy strategy,
const Type *lt, const Type *rt) { … }
bool SemaObjC::MatchTwoMethodDeclarations(const ObjCMethodDecl *left,
const ObjCMethodDecl *right,
MethodMatchStrategy strategy) { … }
static bool isMethodContextSameForKindofLookup(ObjCMethodDecl *Method,
ObjCMethodDecl *MethodInList) { … }
void SemaObjC::addMethodToGlobalList(ObjCMethodList *List,
ObjCMethodDecl *Method) { … }
void SemaObjC::ReadMethodPool(Selector Sel) { … }
void SemaObjC::updateOutOfDateSelector(Selector Sel) { … }
void SemaObjC::AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl,
bool instance) { … }
static bool isAcceptableMethodMismatch(ObjCMethodDecl *chosen,
ObjCMethodDecl *other) { … }
static bool FilterMethodsByTypeBound(ObjCMethodDecl *Method,
const ObjCObjectType *TypeBound) { … }
bool SemaObjC::CollectMultipleMethodsInGlobalPool(
Selector Sel, SmallVectorImpl<ObjCMethodDecl *> &Methods,
bool InstanceFirst, bool CheckTheOther, const ObjCObjectType *TypeBound) { … }
bool SemaObjC::AreMultipleMethodsInGlobalPool(
Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R,
bool receiverIdOrClass, SmallVectorImpl<ObjCMethodDecl *> &Methods) { … }
ObjCMethodDecl *SemaObjC::LookupMethodInGlobalPool(Selector Sel, SourceRange R,
bool receiverIdOrClass,
bool instance) { … }
void SemaObjC::DiagnoseMultipleMethodInGlobalPool(
SmallVectorImpl<ObjCMethodDecl *> &Methods, Selector Sel, SourceRange R,
bool receiverIdOrClass) { … }
ObjCMethodDecl *SemaObjC::LookupImplementedMethodInGlobalPool(Selector Sel) { … }
static void
HelperSelectorsForTypoCorrection(
SmallVectorImpl<const ObjCMethodDecl *> &BestMethod,
StringRef Typo, const ObjCMethodDecl * Method) { … }
static bool HelperIsMethodInObjCType(Sema &S, Selector Sel,
QualType ObjectType) { … }
const ObjCMethodDecl *
SemaObjC::SelectorsForTypoCorrection(Selector Sel, QualType ObjectType) { … }
void SemaObjC::DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID,
ObjCInterfaceDecl *SID) { … }
static void DiagnoseWeakIvars(Sema &S, ObjCImplementationDecl *ID) { … }
static void DiagnoseRetainableFlexibleArrayMember(Sema &S,
ObjCInterfaceDecl *ID) { … }
SemaObjC::ObjCContainerKind SemaObjC::getObjCContainerKind() const { … }
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 void DiagnoseCategoryDirectMembersProtocolConformance(
Sema &S, ObjCProtocolDecl *PDecl, ObjCCategoryDecl *CDecl) { … }
Decl *SemaObjC::ActOnAtEnd(Scope *S, SourceRange AtEnd,
ArrayRef<Decl *> allMethods,
ArrayRef<DeclGroupPtrTy> allTUVars) { … }
static Decl::ObjCDeclQualifier
CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal) { … }
static SemaObjC::ResultTypeCompatibilityKind
CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method,
ObjCInterfaceDecl *CurrentClass) { … }
namespace {
class OverrideSearch { … };
}
void SemaObjC::CheckObjCMethodDirectOverrides(ObjCMethodDecl *method,
ObjCMethodDecl *overridden) { … }
void SemaObjC::CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod,
ObjCInterfaceDecl *CurrentClass,
ResultTypeCompatibilityKind RTC) { … }
static QualType mergeTypeNullabilityForRedecl(Sema &S, SourceLocation loc,
QualType type,
bool usesCSKeyword,
SourceLocation prevLoc,
QualType prevType,
bool prevUsesCSKeyword) { … }
static void mergeInterfaceMethodToImpl(Sema &S,
ObjCMethodDecl *method,
ObjCMethodDecl *prevMethod) { … }
static void checkObjCMethodX86VectorTypes(Sema &SemaRef,
const ObjCMethodDecl *Method) { … }
static void mergeObjCDirectMembers(Sema &S, Decl *CD, ObjCMethodDecl *Method) { … }
static void checkObjCDirectMethodClashes(Sema &S, ObjCInterfaceDecl *IDecl,
ObjCMethodDecl *Method,
ObjCImplDecl *ImpDecl = nullptr) { … }
Decl *SemaObjC::ActOnMethodDeclaration(
Scope *S, SourceLocation MethodLoc, SourceLocation EndLoc,
tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
ArrayRef<SourceLocation> SelectorLocs, Selector Sel,
ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo,
unsigned CNumArgs,
const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodDeclKind,
bool isVariadic, bool MethodDefinition) { … }
bool SemaObjC::CheckObjCDeclScope(Decl *D) { … }
void SemaObjC::ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart,
const IdentifierInfo *ClassName,
SmallVectorImpl<Decl *> &Decls) { … }
VarDecl *SemaObjC::BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType T,
SourceLocation StartLoc,
SourceLocation IdLoc,
const IdentifierInfo *Id,
bool Invalid) { … }
Decl *SemaObjC::ActOnObjCExceptionDecl(Scope *S, Declarator &D) { … }
void SemaObjC::CollectIvarsToConstructOrDestruct(
ObjCInterfaceDecl *OI, SmallVectorImpl<ObjCIvarDecl *> &Ivars) { … }
void SemaObjC::DiagnoseUseOfUnimplementedSelectors() { … }
ObjCIvarDecl *
SemaObjC::GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method,
const ObjCPropertyDecl *&PDecl) const { … }
namespace {
class UnusedBackingIvarChecker
: public RecursiveASTVisitor<UnusedBackingIvarChecker> { … };
}
void SemaObjC::DiagnoseUnusedBackingIvarInAccessor(
Scope *S, const ObjCImplementationDecl *ImplD) { … }
QualType SemaObjC::AdjustParameterTypeForObjCAutoRefCount(
QualType T, SourceLocation NameLoc, TypeSourceInfo *TSInfo) { … }
ObjCInterfaceDecl *SemaObjC::getObjCInterfaceDecl(const IdentifierInfo *&Id,
SourceLocation IdLoc,
bool DoTypoCorrection) { … }
bool SemaObjC::inferObjCARCLifetime(ValueDecl *decl) { … }
ObjCContainerDecl *SemaObjC::getObjCDeclContext() const { … }
void SemaObjC::SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation) { … }
static ObjCIvarDecl::AccessControl
TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility) { … }
Decl *SemaObjC::ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D,
Expr *BitWidth, tok::ObjCKeywordKind Visibility) { … }