#include "clang/AST/ASTContext.h"
#include "clang/AST/Availability.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/AST/TypeLoc.h"
#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Edit/Commit.h"
#include "clang/Edit/Rewriters.h"
#include "clang/Lex/Preprocessor.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/SmallString.h"
#include "llvm/Support/ConvertUTF.h"
#include <optional>
usingnamespaceclang;
usingnamespacesema;
ArrayRef;
ExprResult SemaObjC::ParseObjCStringLiteral(SourceLocation *AtLocs,
ArrayRef<Expr *> Strings) { … }
ExprResult SemaObjC::BuildObjCStringLiteral(SourceLocation AtLoc,
StringLiteral *S) { … }
static bool validateBoxingMethod(Sema &S, SourceLocation Loc,
const ObjCInterfaceDecl *Class,
Selector Sel, const ObjCMethodDecl *Method) { … }
static NSAPI::NSClassIdKindKind
ClassKindFromLiteralKind(SemaObjC::ObjCLiteralKind LiteralKind) { … }
static bool
ValidateObjCLiteralInterfaceDecl(Sema &S, ObjCInterfaceDecl *Decl,
SourceLocation Loc,
SemaObjC::ObjCLiteralKind LiteralKind) { … }
static ObjCInterfaceDecl *
LookupObjCInterfaceDeclForLiteral(Sema &S, SourceLocation Loc,
SemaObjC::ObjCLiteralKind LiteralKind) { … }
static ObjCMethodDecl *getNSNumberFactoryMethod(SemaObjC &S, SourceLocation Loc,
QualType NumberType,
bool isLiteral = false,
SourceRange R = SourceRange()) { … }
ExprResult SemaObjC::BuildObjCNumericLiteral(SourceLocation AtLoc,
Expr *Number) { … }
ExprResult SemaObjC::ActOnObjCBoolLiteral(SourceLocation AtLoc,
SourceLocation ValueLoc, bool Value) { … }
static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element,
QualType T,
bool ArrayLiteral = false) { … }
ExprResult SemaObjC::BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr) { … }
ExprResult SemaObjC::BuildObjCSubscriptExpression(
SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr,
ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod) { … }
ExprResult SemaObjC::BuildObjCArrayLiteral(SourceRange SR,
MultiExprArg Elements) { … }
static void
CheckObjCDictionaryLiteralDuplicateKeys(Sema &S,
ObjCDictionaryLiteral *Literal) { … }
ExprResult SemaObjC::BuildObjCDictionaryLiteral(
SourceRange SR, MutableArrayRef<ObjCDictionaryElement> Elements) { … }
ExprResult SemaObjC::BuildObjCEncodeExpression(SourceLocation AtLoc,
TypeSourceInfo *EncodedTypeInfo,
SourceLocation RParenLoc) { … }
ExprResult SemaObjC::ParseObjCEncodeExpression(SourceLocation AtLoc,
SourceLocation EncodeLoc,
SourceLocation LParenLoc,
ParsedType ty,
SourceLocation RParenLoc) { … }
static bool HelperToDiagnoseMismatchedMethodsInGlobalPool(Sema &S,
SourceLocation AtLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc,
ObjCMethodDecl *Method,
ObjCMethodList &MethList) { … }
static void DiagnoseMismatchedSelectors(Sema &S, SourceLocation AtLoc,
ObjCMethodDecl *Method,
SourceLocation LParenLoc,
SourceLocation RParenLoc,
bool WarnMultipleSelectors) { … }
static ObjCMethodDecl *LookupDirectMethodInMethodList(Sema &S, Selector Sel,
ObjCMethodList &MethList,
bool &onlyDirect,
bool &anyDirect) { … }
static ObjCMethodDecl *LookupDirectMethodInGlobalPool(Sema &S, Selector Sel,
bool &onlyDirect,
bool &anyDirect) { … }
static ObjCMethodDecl *findMethodInCurrentClass(Sema &S, Selector Sel) { … }
ExprResult SemaObjC::ParseObjCSelectorExpression(Selector Sel,
SourceLocation AtLoc,
SourceLocation SelLoc,
SourceLocation LParenLoc,
SourceLocation RParenLoc,
bool WarnMultipleSelectors) { … }
ExprResult SemaObjC::ParseObjCProtocolExpression(IdentifierInfo *ProtocolId,
SourceLocation AtLoc,
SourceLocation ProtoLoc,
SourceLocation LParenLoc,
SourceLocation ProtoIdLoc,
SourceLocation RParenLoc) { … }
ObjCMethodDecl *SemaObjC::tryCaptureObjCSelf(SourceLocation Loc) { … }
static QualType stripObjCInstanceType(ASTContext &Context, QualType T) { … }
static QualType getBaseMessageSendResultType(Sema &S,
QualType ReceiverType,
ObjCMethodDecl *Method,
bool isClassMessage,
bool isSuperMessage) { … }
QualType SemaObjC::getMessageSendResultType(const Expr *Receiver,
QualType ReceiverType,
ObjCMethodDecl *Method,
bool isClassMessage,
bool isSuperMessage) { … }
static const ObjCMethodDecl *
findExplicitInstancetypeDeclarer(const ObjCMethodDecl *MD,
QualType instancetype) { … }
void SemaObjC::EmitRelatedResultTypeNoteForReturn(QualType destType) { … }
void SemaObjC::EmitRelatedResultTypeNote(const Expr *E) { … }
bool SemaObjC::CheckMessageArgumentTypes(
const Expr *Receiver, QualType ReceiverType, MultiExprArg Args,
Selector Sel, ArrayRef<SourceLocation> SelectorLocs, ObjCMethodDecl *Method,
bool isClassMessage, bool isSuperMessage, SourceLocation lbrac,
SourceLocation rbrac, SourceRange RecRange, QualType &ReturnType,
ExprValueKind &VK) { … }
bool SemaObjC::isSelfExpr(Expr *RExpr) { … }
bool SemaObjC::isSelfExpr(Expr *receiver, const ObjCMethodDecl *method) { … }
ObjCMethodDecl *SemaObjC::LookupMethodInObjectType(Selector sel, QualType type,
bool isInstance) { … }
ObjCMethodDecl *SemaObjC::LookupMethodInQualifiedType(
Selector Sel, const ObjCObjectPointerType *OPT, bool Instance) { … }
ExprResult SemaObjC::HandleExprPropertyRefExpr(
const ObjCObjectPointerType *OPT, Expr *BaseExpr, SourceLocation OpLoc,
DeclarationName MemberName, SourceLocation MemberLoc,
SourceLocation SuperLoc, QualType SuperType, bool Super) { … }
ExprResult SemaObjC::ActOnClassPropertyRefExpr(
const IdentifierInfo &receiverName, const IdentifierInfo &propertyName,
SourceLocation receiverNameLoc, SourceLocation propertyNameLoc) { … }
namespace {
class ObjCInterfaceOrSuperCCC final : public CorrectionCandidateCallback { … };
}
SemaObjC::ObjCMessageKind
SemaObjC::getObjCMessageKind(Scope *S, IdentifierInfo *Name,
SourceLocation NameLoc, bool IsSuper,
bool HasTrailingDot, ParsedType &ReceiverType) { … }
ExprResult SemaObjC::ActOnSuperMessage(Scope *S, SourceLocation SuperLoc,
Selector Sel, SourceLocation LBracLoc,
ArrayRef<SourceLocation> SelectorLocs,
SourceLocation RBracLoc,
MultiExprArg Args) { … }
ExprResult SemaObjC::BuildClassMessageImplicit(QualType ReceiverType,
bool isSuperReceiver,
SourceLocation Loc, Selector Sel,
ObjCMethodDecl *Method,
MultiExprArg Args) { … }
static void applyCocoaAPICheck(Sema &S, const ObjCMessageExpr *Msg,
unsigned DiagID,
bool (*refactor)(const ObjCMessageExpr *,
const NSAPI &, edit::Commit &)) { … }
static void checkCocoaAPI(Sema &S, const ObjCMessageExpr *Msg) { … }
static void checkFoundationAPI(Sema &S, SourceLocation Loc,
const ObjCMethodDecl *Method,
ArrayRef<Expr *> Args, QualType ReceiverType,
bool IsClassObjectCall) { … }
static void
DiagnoseCStringFormatDirectiveInObjCAPI(Sema &S,
ObjCMethodDecl *Method,
Selector Sel,
Expr **Args, unsigned NumArgs) { … }
ExprResult SemaObjC::BuildClassMessage(
TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType,
SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method,
SourceLocation LBracLoc, ArrayRef<SourceLocation> SelectorLocs,
SourceLocation RBracLoc, MultiExprArg ArgsIn, bool isImplicit) { … }
ExprResult SemaObjC::ActOnClassMessage(Scope *S, ParsedType Receiver,
Selector Sel, SourceLocation LBracLoc,
ArrayRef<SourceLocation> SelectorLocs,
SourceLocation RBracLoc,
MultiExprArg Args) { … }
ExprResult SemaObjC::BuildInstanceMessageImplicit(
Expr *Receiver, QualType ReceiverType, SourceLocation Loc, Selector Sel,
ObjCMethodDecl *Method, MultiExprArg Args) { … }
static bool isMethodDeclaredInRootProtocol(Sema &S, const ObjCMethodDecl *M) { … }
ExprResult SemaObjC::BuildInstanceMessage(
Expr *Receiver, QualType ReceiverType, SourceLocation SuperLoc,
Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc,
ArrayRef<SourceLocation> SelectorLocs, SourceLocation RBracLoc,
MultiExprArg ArgsIn, bool isImplicit) { … }
static void RemoveSelectorFromWarningCache(SemaObjC &S, Expr *Arg) { … }
ExprResult SemaObjC::ActOnInstanceMessage(Scope *S, Expr *Receiver,
Selector Sel, SourceLocation LBracLoc,
ArrayRef<SourceLocation> SelectorLocs,
SourceLocation RBracLoc,
MultiExprArg Args) { … }
enum ARCConversionTypeClass { … };
static bool isAnyRetainable(ARCConversionTypeClass ACTC) { … }
static bool isAnyCLike(ARCConversionTypeClass ACTC) { … }
static ARCConversionTypeClass classifyTypeForARCConversion(QualType type) { … }
namespace {
enum ACCResult { … };
ACCResult merge(ACCResult left, ACCResult right) { … }
class ARCCastChecker : public StmtVisitor<ARCCastChecker, ACCResult> { … };
}
bool SemaObjC::isKnownName(StringRef name) { … }
template <typename DiagBuilderT>
static void addFixitForObjCARCConversion(
Sema &S, DiagBuilderT &DiagB, CheckedConversionKind CCK,
SourceLocation afterLParen, QualType castType, Expr *castExpr,
Expr *realCast, const char *bridgeKeyword, const char *CFBridgeName) { … }
template <typename T>
static inline T *getObjCBridgeAttr(const TypedefType *TD) { … }
static ObjCBridgeRelatedAttr *ObjCBridgeRelatedAttrFromType(QualType T,
TypedefNameDecl *&TDNDecl) { … }
static void diagnoseObjCARCConversion(Sema &S, SourceRange castRange,
QualType castType,
ARCConversionTypeClass castACTC,
Expr *castExpr, Expr *realCast,
ARCConversionTypeClass exprACTC,
CheckedConversionKind CCK) { … }
template <typename TB>
static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr,
bool &HadTheAttribute, bool warn) { … }
template <typename TB>
static bool CheckObjCBridgeCFCast(Sema &S, QualType castType, Expr *castExpr,
bool &HadTheAttribute, bool warn) { … }
void SemaObjC::CheckTollFreeBridgeCast(QualType castType, Expr *castExpr) { … }
void SemaObjC::CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr) { … }
bool SemaObjC::CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr,
CastKind &Kind) { … }
bool SemaObjC::checkObjCBridgeRelatedComponents(
SourceLocation Loc, QualType DestType, QualType SrcType,
ObjCInterfaceDecl *&RelatedClass, ObjCMethodDecl *&ClassMethod,
ObjCMethodDecl *&InstanceMethod, TypedefNameDecl *&TDNDecl, bool CfToNs,
bool Diagnose) { … }
bool SemaObjC::CheckObjCBridgeRelatedConversions(SourceLocation Loc,
QualType DestType,
QualType SrcType,
Expr *&SrcExpr,
bool Diagnose) { … }
SemaObjC::ARCConversionResult
SemaObjC::CheckObjCConversion(SourceRange castRange, QualType castType,
Expr *&castExpr, CheckedConversionKind CCK,
bool Diagnose, bool DiagnoseCFAudited,
BinaryOperatorKind Opc) { … }
void SemaObjC::diagnoseARCUnbridgedCast(Expr *e) { … }
Expr *SemaObjC::stripARCUnbridgedCast(Expr *e) { … }
bool SemaObjC::CheckObjCARCUnavailableWeakConversion(QualType castType,
QualType exprType) { … }
static Expr *maybeUndoReclaimObject(Expr *e) { … }
ExprResult SemaObjC::BuildObjCBridgedCast(SourceLocation LParenLoc,
ObjCBridgeCastKind Kind,
SourceLocation BridgeKeywordLoc,
TypeSourceInfo *TSInfo,
Expr *SubExpr) { … }
ExprResult SemaObjC::ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc,
ObjCBridgeCastKind Kind,
SourceLocation BridgeKeywordLoc,
ParsedType Type,
SourceLocation RParenLoc,
Expr *SubExpr) { … }
DeclResult SemaObjC::LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S,
IdentifierInfo *II) { … }
ExprResult SemaObjC::LookupInObjCMethod(LookupResult &Lookup, Scope *S,
IdentifierInfo *II,
bool AllowBuiltinCreation) { … }
ExprResult SemaObjC::BuildIvarRefExpr(Scope *S, SourceLocation Loc,
ObjCIvarDecl *IV) { … }
QualType SemaObjC::FindCompositeObjCPointerType(ExprResult &LHS,
ExprResult &RHS,
SourceLocation QuestionLoc) { … }
bool SemaObjC::CheckConversionToObjCLiteral(QualType DstType, Expr *&Exp,
bool Diagnose) { … }
ExprResult SemaObjC::ActOnObjCBoolLiteral(SourceLocation OpLoc,
tok::TokenKind Kind) { … }
ExprResult SemaObjC::ActOnObjCAvailabilityCheckExpr(
llvm::ArrayRef<AvailabilitySpec> AvailSpecs, SourceLocation AtLoc,
SourceLocation RParen) { … }
CastKind SemaObjC::PrepareCastToObjCObjectPointer(ExprResult &E) { … }
SemaObjC::ObjCLiteralKind SemaObjC::CheckLiteralKind(Expr *FromE) { … }