clang: lib/Sema/SemaExprObjC.cpp File Reference (original) (raw)

Go to the source code of this file.

Functions
static bool validateBoxingMethod (Sema &S, SourceLocation Loc, const ObjCInterfaceDecl *Class, Selector Sel, const ObjCMethodDecl *Method)
Emits an error if the given method does not exist, or if the return type is not an Objective-C object.
static NSAPI::NSClassIdKindKind ClassKindFromLiteralKind (SemaObjC::ObjCLiteralKind LiteralKind)
Maps ObjCLiteralKind to NSClassIdKindKind.
static bool ValidateObjCLiteralInterfaceDecl (Sema &S, ObjCInterfaceDecl *Decl, SourceLocation Loc, SemaObjC::ObjCLiteralKind LiteralKind)
Validates ObjCInterfaceDecl availability.
enum ARCConversionTypeClass { ACTC_none, ACTC_retainable, ACTC_indirectRetainable, ACTC_voidPtr, ACTC_coreFoundation }
static ObjCInterfaceDecl * LookupObjCInterfaceDeclForLiteral (Sema &S, SourceLocation Loc, SemaObjC::ObjCLiteralKind LiteralKind)
Looks up ObjCInterfaceDecl of a given NSClassIdKindKind.
static ObjCMethodDecl * getNSNumberFactoryMethod (SemaObjC &S, SourceLocation Loc, QualType NumberType, bool isLiteral=false, SourceRange R=SourceRange())
Retrieve the NSNumber factory method that should be used to create an Objective-C literal for the given type.
static ExprResult CheckObjCCollectionLiteralElement (Sema &S, Expr *Element, QualType T, bool ArrayLiteral=false)
Check that the given expression is a valid element of an Objective-C collection literal.
static void CheckObjCDictionaryLiteralDuplicateKeys (Sema &S, ObjCDictionaryLiteral *Literal)
Check for duplicate keys in an ObjC dictionary literal.
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)
static QualType stripObjCInstanceType (ASTContext &Context, QualType T)
static QualType getBaseMessageSendResultType (Sema &S, QualType ReceiverType, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage)
Determine the result type of a message send based on the receiver type, method, and the kind of message send.
static const ObjCMethodDecl * findExplicitInstancetypeDeclarer (const ObjCMethodDecl *MD, QualType instancetype)
Look for an ObjC method whose result type exactly matches the given type.
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)
Diagnose use of s directive in an NSString which is being passed as formatting string to formatting method.
static bool isMethodDeclaredInRootProtocol (Sema &S, const ObjCMethodDecl *M)
static void RemoveSelectorFromWarningCache (SemaObjC &S, Expr *Arg)
static bool isAnyRetainable (ARCConversionTypeClass ACTC)
static bool isAnyCLike (ARCConversionTypeClass ACTC)
static ARCConversionTypeClass classifyTypeForARCConversion (QualType type)
template
static void addFixitForObjCARCConversion (Sema &S, DiagBuilderT &DiagB, CheckedConversionKind CCK, SourceLocation afterLParen, QualType castType, Expr *castExpr, Expr *realCast, const char *bridgeKeyword, const char *CFBridgeName)
template
static 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
static bool CheckObjCBridgeNSCast (Sema &S, QualType castType, Expr *castExpr, bool &HadTheAttribute, bool warn)
template
static bool CheckObjCBridgeCFCast (Sema &S, QualType castType, Expr *castExpr, bool &HadTheAttribute, bool warn)
static Expr * maybeUndoReclaimObject (Expr *e)
Look for an ObjCReclaimReturnedObject cast and destroy it.

ARCConversionTypeClass

Enumerator
ACTC_none int, void, struct A
ACTC_retainable id, void (^)()
ACTC_indirectRetainable id*, id***, void (^*)(),
ACTC_voidPtr void* might be a normal C type, or it might a CF type.
ACTC_coreFoundation struct A*

Definition at line 3442 of file SemaExprObjC.cpp.

addFixitForObjCARCConversion()

template

Definition at line 3748 of file SemaExprObjC.cpp.

References clang::ast_matchers::castExpr, clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateReplacement(), clang::CStyleCast, clang::ForBuiltinOverloadedOp, clang::FunctionalCast, clang::QualType::getAsString(), clang::Sema::getLangOpts(), clang::Sema::getLocForEndOfToken(), clang::Sema::getSourceManager(), clang::Stmt::getSourceRange(), clang::Expr::IgnoreImpCasts(), clang::Implicit, clang::Lexer::isAsciiIdentifierContinueChar(), clang::OtherCast, Range, and SM.

Referenced by diagnoseObjCARCConversion().

applyCocoaAPICheck()

Definition at line 2449 of file SemaExprObjC.cpp.

References clang::edit::Commit::Act_Insert, clang::edit::Commit::Act_InsertFromRange, clang::edit::Commit::Act_Remove, clang::edit::Commit::Edit::BeforePrev, clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateInsertionFromRange(), clang::FixItHint::CreateRemoval(), clang::SemaBase::Diag(), clang::Sema::Diags, E, clang::edit::Commit::edit_begin(), clang::edit::Commit::edit_end(), clang::Expr::getExprLoc(), clang::edit::Commit::Edit::getFileRange(), clang::edit::Commit::Edit::getInsertFromRange(), clang::ObjCMessageExpr::getSelector(), clang::Stmt::getSourceRange(), clang::edit::Commit::isCommitable(), clang::DiagnosticsEngine::isIgnored(), clang::edit::Commit::Edit::Kind, clang::Sema::LangOpts, clang::SemaObjC::NSAPIObj, clang::Sema::ObjC(), clang::edit::Commit::Edit::OrigLoc, SM, clang::Sema::SourceMgr, and clang::edit::Commit::Edit::Text.

Referenced by checkCocoaAPI().

checkCocoaAPI()

checkFoundationAPI()

CheckObjCBridgeCFCast()

Definition at line 4066 of file SemaExprObjC.cpp.

References clang::ast_matchers::castExpr, clang::Sema::Context, clang::SemaBase::Diag(), clang::Type::getAs(), clang::TypeDecl::getBeginLoc(), clang::LookupResult::getFoundDecl(), clang::TypedefNameDecl::getUnderlyingType(), clang::ObjCInterfaceDecl::isSuperClassOf(), clang::Sema::LookupName(), clang::Sema::LookupOrdinaryName, clang::ASTContext::QIdProtocolsAdoptObjCObjectProtocols(), clang::T, and clang::Sema::TUScope.

CheckObjCBridgeNSCast()

Definition at line 4003 of file SemaExprObjC.cpp.

References clang::ast_matchers::castExpr, clang::Sema::Context, clang::SemaBase::Diag(), clang::Type::getAs(), clang::Type::getAsObjCInterfacePointerType(), clang::TypeDecl::getBeginLoc(), clang::LookupResult::getFoundDecl(), clang::Type::getPointeeType(), clang::TypedefNameDecl::getUnderlyingType(), clang::Type::isObjCIdType(), clang::ObjCInterfaceDecl::isSuperClassOf(), clang::Sema::LookupName(), clang::Sema::LookupOrdinaryName, clang::ASTContext::ObjCObjectAdoptsQTypeProtocols(), clang::T, and clang::Sema::TUScope.

CheckObjCCollectionLiteralElement()

Check that the given expression is a valid element of an Objective-C collection literal.

Definition at line 392 of file SemaExprObjC.cpp.

References clang::SemaObjC::BuildObjCNumericLiteral(), clang::SemaObjC::BuildObjCStringLiteral(), clang::Sema::CheckPlaceholderExpr(), clang::Sema::Context, clang::InitializationKind::CreateCopy(), clang::FixItHint::CreateInsertion(), clang::Sema::DefaultLvalueConversion(), clang::SemaBase::Diag(), clang::ExprError(), clang::Stmt::getBeginLoc(), clang::Sema::getLangOpts(), clang::Stmt::getSourceRange(), clang::StringLiteral::getString(), clang::Expr::getType(), clang::InitializedEntity::InitializeParameter(), clang::SemaObjC::NSAPIObj, clang::Sema::ObjC(), clang::Sema::PerformCopyInitialization(), clang::Result, clang::Seq, and clang::T.

Referenced by clang::SemaObjC::BuildObjCArrayLiteral().

CheckObjCDictionaryLiteralDuplicateKeys()

classifyTypeForARCConversion()

Definition at line 3471 of file SemaExprObjC.cpp.

References ACTC_coreFoundation, ACTC_indirectRetainable, ACTC_none, ACTC_retainable, ACTC_voidPtr, and clang::ast_matchers::type.

Referenced by clang::SemaObjC::CheckObjCBridgeRelatedCast(), clang::SemaObjC::CheckObjCBridgeRelatedConversions(), clang::SemaObjC::CheckObjCConversion(), clang::SemaObjC::CheckTollFreeBridgeCast(), clang::SemaObjC::CheckTollFreeBridgeStaticCast(), and clang::SemaObjC::diagnoseARCUnbridgedCast().

ClassKindFromLiteralKind()

Maps ObjCLiteralKind to NSClassIdKindKind.

Definition at line 176 of file SemaExprObjC.cpp.

References clang::NSAPI::ClassId_NSArray, clang::NSAPI::ClassId_NSDictionary, clang::NSAPI::ClassId_NSNumber, clang::NSAPI::ClassId_NSString, clang::NSAPI::ClassId_NSValue, clang::SemaObjC::LK_Array, clang::SemaObjC::LK_Block, clang::SemaObjC::LK_Boxed, clang::SemaObjC::LK_Dictionary, clang::SemaObjC::LK_None, clang::SemaObjC::LK_Numeric, and clang::SemaObjC::LK_String.

Referenced by LookupObjCInterfaceDeclForLiteral(), and ValidateObjCLiteralInterfaceDecl().

DiagnoseCStringFormatDirectiveInObjCAPI()

Diagnose use of s directive in an NSString which is being passed as formatting string to formatting method.

Definition at line 2542 of file SemaExprObjC.cpp.

References clang::SemaBase::Diag(), clang::Sema::FormatStringHasSArg(), clang::NamedDecl::getDeclName(), clang::Expr::getExprLoc(), clang::SemaObjC::GetFormatNSStringIdx(), clang::Decl::getLocation(), clang::StringLiteral::getString(), clang::Selector::getStringFormatFamily(), clang::Expr::IgnoreParenImpCasts(), clang::Sema::ObjC(), clang::SFF_NSString, and clang::Decl::specific_attrs().

Referenced by clang::SemaObjC::BuildClassMessage(), and clang::SemaObjC::BuildInstanceMessage().

DiagnoseMismatchedSelectors()

diagnoseObjCARCConversion()

Definition at line 3870 of file SemaExprObjC.cpp.

References ACTC_coreFoundation, ACTC_indirectRetainable, ACTC_none, ACTC_retainable, ACTC_voidPtr, addFixitForObjCARCConversion(), clang::ast_matchers::castExpr, clang::Sema::Context, clang::SemaBase::Diag(), clang::SourceRange::getBegin(), clang::Sema::getLocForEndOfToken(), isAnyRetainable(), clang::Type::isBlockPointerType(), clang::Sema::isCast(), clang::SemaObjC::isKnownName(), clang::Type::isPointerType(), clang::SourceLocation::isValid(), clang::SourceRange::isValid(), clang::Sema::makeUnavailableInSystemHeader(), clang::Sema::ObjC(), ObjCBridgeRelatedAttrFromType(), and clang::OtherCast.

Referenced by clang::SemaObjC::CheckObjCConversion(), and clang::SemaObjC::diagnoseARCUnbridgedCast().

findExplicitInstancetypeDeclarer()

findMethodInCurrentClass()

getBaseMessageSendResultType()

Determine the result type of a message send based on the receiver type, method, and the kind of message send.

This is the "base" result type, which will still need to be adjusted to account for nullability.

Definition at line 1460 of file SemaExprObjC.cpp.

References clang::Class, clang::Sema::Context, clang::Type::getAsObjCInterfaceType(), clang::ASTContext::getAttributedType(), clang::Sema::getCurMethodDecl(), clang::Type::getNullability(), clang::ASTContext::getObjCInterfaceType(), clang::ASTContext::getObjCObjectPointerType(), clang::ObjCMethodDecl::getSendResultType(), clang::ObjCMethodDecl::hasRelatedResultType(), clang::ObjCMethodDecl::isInstanceMethod(), clang::Type::isObjCClassType(), clang::Type::isObjCQualifiedClassType(), stripObjCInstanceType(), clang::AttributedType::stripOuterNullability(), and clang::ast_matchers::type.

Referenced by clang::SemaObjC::getMessageSendResultType().

getNSNumberFactoryMethod()

Retrieve the NSNumber factory method that should be used to create an Objective-C literal for the given type.

Definition at line 248 of file SemaExprObjC.cpp.

References clang::Sema::Context, clang::ParmVarDecl::Create(), clang::ObjCMethodDecl::Create(), clang::SemaBase::Diag(), clang::IdentifierTable::get(), clang::Sema::getLangOpts(), clang::ASTContext::getObjCInterfaceType(), clang::ASTContext::getObjCObjectPointerType(), clang::ASTContext::Idents, clang::SemaObjC::LK_Numeric, Loc, LookupObjCInterfaceDeclForLiteral(), clang::Required, clang::SC_None, clang::SemaBase::SemaRef, clang::ObjCMethodDecl::setMethodParams(), and validateBoxingMethod().

Referenced by clang::SemaObjC::BuildObjCBoxedExpr(), and clang::SemaObjC::BuildObjCNumericLiteral().

getObjCBridgeAttr()

template

static T * getObjCBridgeAttr ( const TypedefType * TD) inlinestatic

HelperToDiagnoseMismatchedMethodsInGlobalPool()

Definition at line 1178 of file SemaExprObjC.cpp.

References clang::FixItHint::CreateInsertion(), clang::SemaBase::Diag(), clang::Decl::getDeclContext(), clang::NamedDecl::getDeclName(), clang::Decl::getLocation(), clang::ObjCMethodList::getMethod(), clang::ObjCMethodList::getNext(), clang::ObjCMethodDecl::getSelector(), clang::SemaObjC::MatchTwoMethodDeclarations(), clang::SemaObjC::MMS_loose, and clang::Sema::ObjC().

Referenced by DiagnoseMismatchedSelectors().

isAnyCLike()

isAnyRetainable()

isMethodDeclaredInRootProtocol()

LookupDirectMethodInGlobalPool()

LookupDirectMethodInMethodList()

LookupObjCInterfaceDeclForLiteral()

Looks up ObjCInterfaceDecl of a given NSClassIdKindKind.

Used to create ObjC literals, such as NSDictionary (}), NSArray (@[]) and Boxed Expressions (@())

Definition at line 225 of file SemaExprObjC.cpp.

References ClassKindFromLiteralKind(), clang::Sema::Context, clang::ObjCInterfaceDecl::Create(), clang::Sema::getLangOpts(), clang::ASTContext::getTranslationUnitDecl(), Loc, clang::Sema::LookupOrdinaryName, clang::Sema::LookupSingleName(), clang::SemaObjC::NSAPIObj, clang::Sema::ObjC(), clang::Sema::TUScope, and ValidateObjCLiteralInterfaceDecl().

Referenced by clang::SemaObjC::BuildObjCArrayLiteral(), clang::SemaObjC::BuildObjCBoxedExpr(), clang::SemaObjC::BuildObjCDictionaryLiteral(), and getNSNumberFactoryMethod().

maybeUndoReclaimObject()

static Expr * maybeUndoReclaimObject ( Expr * e) static

ObjCBridgeRelatedAttrFromType()

RemoveSelectorFromWarningCache()

static void RemoveSelectorFromWarningCache ( SemaObjC & S, Expr * Arg ) static

stripObjCInstanceType()

validateBoxingMethod()

ValidateObjCLiteralInterfaceDecl()