clang API Documentation

Public Types | Public Member Functions | Static Public Member Functions | Friends
clang::ObjCMessageExpr Class Reference

An expression that sends a message to the given Objective-C object or class. More...

#include <ExprObjC.h>

Inheritance diagram for clang::ObjCMessageExpr:
Inheritance graph
[legend]
Collaboration diagram for clang::ObjCMessageExpr:
Collaboration graph
[legend]

List of all members.

Public Types

enum  ReceiverKind { Class = 0, Instance, SuperClass, SuperInstance }
 The kind of receiver this message is sending to. More...
typedef ExprIterator arg_iterator
typedef ConstExprIterator const_arg_iterator

Public Member Functions

bool isImplicit () const
 Indicates whether the message send was implicitly generated by the implementation. If false, it was written explicitly in the source code.
ReceiverKind getReceiverKind () const
 Determine the kind of receiver that this message is being sent to.
SourceRange getReceiverRange () const
 Source range of the receiver.
bool isInstanceMessage () const
 Determine whether this is an instance message to either a computed object or to super.
bool isClassMessage () const
 Determine whether this is an class message to either a specified class or to super.
ExprgetInstanceReceiver ()
 Returns the object expression (receiver) for an instance message, or null for a message that is not an instance message.
const ExprgetInstanceReceiver () const
void setInstanceReceiver (Expr *rec)
 Turn this message send into an instance message that computes the receiver object with the given expression.
QualType getClassReceiver () const
 Returns the type of a class message send, or NULL if the message is not a class message.
TypeSourceInfogetClassReceiverTypeInfo () const
 Returns a type-source information of a class message send, or NULL if the message is not a class message.
void setClassReceiver (TypeSourceInfo *TSInfo)
SourceLocation getSuperLoc () const
 Retrieve the location of the 'super' keyword for a class or instance message to 'super', otherwise an invalid source location.
QualType getReceiverType () const
 Retrieve the receiver type to which this message is being directed.
ObjCInterfaceDeclgetReceiverInterface () const
 Retrieve the Objective-C interface to which this message is being directed, if known.
QualType getSuperType () const
 Retrieve the type referred to by 'super'.
void setSuper (SourceLocation Loc, QualType T, bool IsInstanceSuper)
Selector getSelector () const
void setSelector (Selector S)
const ObjCMethodDeclgetMethodDecl () const
ObjCMethodDeclgetMethodDecl ()
void setMethodDecl (ObjCMethodDecl *MD)
ObjCMethodFamily getMethodFamily () const
unsigned getNumArgs () const
 Return the number of actual arguments in this message, not counting the receiver.
Expr ** getArgs ()
 Retrieve the arguments to this message, not including the receiver.
const Expr *const * getArgs () const
ExprgetArg (unsigned Arg)
 getArg - Return the specified argument.
const ExprgetArg (unsigned Arg) const
void setArg (unsigned Arg, Expr *ArgExpr)
 setArg - Set the specified argument.
bool isDelegateInitCall () const
void setDelegateInitCall (bool isDelegate)
SourceLocation getLeftLoc () const
SourceLocation getRightLoc () const
SourceLocation getSelectorStartLoc () const
SourceLocation getSelectorLoc (unsigned Index) const
void getSelectorLocs (SmallVectorImpl< SourceLocation > &SelLocs) const
unsigned getNumSelectorLocs () const
void setSourceRange (SourceRange R)
SourceLocation getLocStart () const LLVM_READONLY
SourceLocation getLocEnd () const LLVM_READONLY
child_range children ()
arg_iterator arg_begin ()
arg_iterator arg_end ()
const_arg_iterator arg_begin () const
const_arg_iterator arg_end () const

Static Public Member Functions

static ObjCMessageExprCreate (const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, Selector Sel, ArrayRef< SourceLocation > SelLocs, ObjCMethodDecl *Method, ArrayRef< Expr * > Args, SourceLocation RBracLoc, bool isImplicit)
 Create a message send to super.
static ObjCMessageExprCreate (const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, TypeSourceInfo *Receiver, Selector Sel, ArrayRef< SourceLocation > SelLocs, ObjCMethodDecl *Method, ArrayRef< Expr * > Args, SourceLocation RBracLoc, bool isImplicit)
 Create a class message send.
static ObjCMessageExprCreate (const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, Expr *Receiver, Selector Sel, ArrayRef< SourceLocation > SeLocs, ObjCMethodDecl *Method, ArrayRef< Expr * > Args, SourceLocation RBracLoc, bool isImplicit)
 Create an instance message send.
static ObjCMessageExprCreateEmpty (const ASTContext &Context, unsigned NumArgs, unsigned NumStoredSelLocs)
 Create an empty Objective-C message expression, to be filled in by subsequent calls.
static bool classof (const Stmt *T)

Friends

class ASTStmtReader
class ASTStmtWriter

Detailed Description

An expression that sends a message to the given Objective-C object or class.

The following contains two message send expressions:

   [[NSString alloc] initWithString:@"Hello"]

The innermost message send invokes the "alloc" class method on the NSString class, while the outermost message send invokes the "initWithString" instance method on the object returned from NSString's "alloc". In all, an Objective-C message send can take on four different (although related) forms:

1. Send to an object instance. 2. Send to a class. 3. Send to the superclass instance of the current class. 4. Send to the superclass of the current class.

All four kinds of message sends are modeled by the ObjCMessageExpr class, and can be distinguished via getReceiverKind(). Example:

Definition at line 879 of file ExprObjC.h.


Member Typedef Documentation

Definition at line 1371 of file ExprObjC.h.

Definition at line 1372 of file ExprObjC.h.


Member Enumeration Documentation

The kind of receiver this message is sending to.

Enumerator:
Class 

The receiver is a class.

Instance 

The receiver is an object instance.

SuperClass 

The receiver is a superclass.

SuperInstance 

The receiver is the instance of the superclass object.

Definition at line 1019 of file ExprObjC.h.


Member Function Documentation

Definition at line 1374 of file ExprObjC.h.

References getArgs().

Referenced by clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr().

Definition at line 1378 of file ExprObjC.h.

References getArgs().

Definition at line 1375 of file ExprObjC.h.

References getArgs().

Referenced by clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr().

Definition at line 1381 of file ExprObjC.h.

References getArgs().

Reimplemented from clang::Stmt.

Definition at line 4076 of file Expr.cpp.

References getArgs(), getNumArgs(), getReceiverKind(), and Instance.

static bool clang::ObjCMessageExpr::classof ( const Stmt T) [inline, static]

Reimplemented from clang::Expr.

Definition at line 1364 of file ExprObjC.h.

References clang::Stmt::getStmtClass().

ObjCMessageExpr * ObjCMessageExpr::Create ( const ASTContext Context,
QualType  T,
ExprValueKind  VK,
SourceLocation  LBracLoc,
SourceLocation  SuperLoc,
bool  IsInstanceSuper,
QualType  SuperType,
Selector  Sel,
ArrayRef< SourceLocation SelLocs,
ObjCMethodDecl Method,
ArrayRef< Expr * >  Args,
SourceLocation  RBracLoc,
bool  isImplicit 
) [static]

Create a message send to super.

Parameters:
ContextThe ASTContext in which this expression will be created.
TThe result type of this message.
VKThe value kind of this message. A message returning a l-value or r-value reference will be an l-value or x-value, respectively.
LBracLocThe location of the open square bracket '['.
SuperLocThe location of the "super" keyword.
IsInstanceSuperWhether this is an instance "super" message (otherwise, it's a class "super" message).
SelThe selector used to determine which method gets called.
MethodThe Objective-C method against which this message send was type-checked. May be NULL.
ArgsThe message send arguments.
RBracLocThe location of the closing square bracket ']'.

Definition at line 3514 of file Expr.cpp.

References isImplicit().

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

ObjCMessageExpr * ObjCMessageExpr::Create ( const ASTContext Context,
QualType  T,
ExprValueKind  VK,
SourceLocation  LBracLoc,
TypeSourceInfo Receiver,
Selector  Sel,
ArrayRef< SourceLocation SelLocs,
ObjCMethodDecl Method,
ArrayRef< Expr * >  Args,
SourceLocation  RBracLoc,
bool  isImplicit 
) [static]

Create a class message send.

Parameters:
ContextThe ASTContext in which this expression will be created.
TThe result type of this message.
VKThe value kind of this message. A message returning a l-value or r-value reference will be an l-value or x-value, respectively.
LBracLocThe location of the open square bracket '['.
ReceiverThe type of the receiver, including source-location information.
SelThe selector used to determine which method gets called.
MethodThe Objective-C method against which this message send was type-checked. May be NULL.
ArgsThe message send arguments.
RBracLocThe location of the closing square bracket ']'.

Definition at line 3539 of file Expr.cpp.

References isImplicit().

ObjCMessageExpr * ObjCMessageExpr::Create ( const ASTContext Context,
QualType  T,
ExprValueKind  VK,
SourceLocation  LBracLoc,
Expr Receiver,
Selector  Sel,
ArrayRef< SourceLocation SeLocs,
ObjCMethodDecl Method,
ArrayRef< Expr * >  Args,
SourceLocation  RBracLoc,
bool  isImplicit 
) [static]

Create an instance message send.

Parameters:
ContextThe ASTContext in which this expression will be created.
TThe result type of this message.
VKThe value kind of this message. A message returning a l-value or r-value reference will be an l-value or x-value, respectively.
LBracLocThe location of the open square bracket '['.
ReceiverThe expression used to produce the object that will receive this message.
SelThe selector used to determine which method gets called.
MethodThe Objective-C method against which this message send was type-checked. May be NULL.
ArgsThe message send arguments.
RBracLocThe location of the closing square bracket ']'.

Definition at line 3562 of file Expr.cpp.

References isImplicit().

ObjCMessageExpr * ObjCMessageExpr::CreateEmpty ( const ASTContext Context,
unsigned  NumArgs,
unsigned  NumStoredSelLocs 
) [static]

Create an empty Objective-C message expression, to be filled in by subsequent calls.

Parameters:
ContextThe context in which the message send will be created.
NumArgsThe number of message arguments, not including the receiver.

Definition at line 3585 of file Expr.cpp.

const Expr* clang::ObjCMessageExpr::getArg ( unsigned  Arg) const [inline]

Definition at line 1311 of file ExprObjC.h.

References getArgs().

Retrieve the arguments to this message, not including the receiver.

Definition at line 1299 of file ExprObjC.h.

Referenced by arg_begin(), arg_end(), children(), getArg(), getSelectorLoc(), and setArg().

const Expr* const* clang::ObjCMessageExpr::getArgs ( ) const [inline]

Definition at line 1302 of file ExprObjC.h.

Returns the type of a class message send, or NULL if the message is not a class message.

Definition at line 1192 of file ExprObjC.h.

References getClassReceiverTypeInfo().

Referenced by clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr(), GetAssumedMessageSendExprType(), getReceiverType(), and maybeAdjustInterfaceForSubscriptingCheck().

Returns a type-source information of a class message send, or NULL if the message is not a class message.

Definition at line 1201 of file ExprObjC.h.

References Class, and getReceiverKind().

Referenced by getClassReceiver(), and getReceiverRange().

Definition at line 1179 of file ExprObjC.h.

References getInstanceReceiver().

Definition at line 1327 of file ExprObjC.h.

Reimplemented from clang::Stmt.

Definition at line 1362 of file ExprObjC.h.

Reimplemented from clang::Stmt.

Definition at line 1361 of file ExprObjC.h.

Referenced by getSelectorStartLoc().

Definition at line 1276 of file ExprObjC.h.

Retrieve the Objective-C interface to which this message is being directed, if known.

This routine cross-cuts all of the different kinds of message sends to determine what the underlying (statically known) type of the receiver will be; use getReceiverKind() to determine whether the message is a class or an instance method, whether it is a send to super or not, etc.

Returns:
The Objective-C interface if known, otherwise NULL.

Definition at line 3656 of file Expr.cpp.

References clang::Type::getAs(), and getReceiverType().

Referenced by checkForLiteralCreation(), getMethodReceiverIfKnownImmutable(), clang::ObjCMethodCall::getRuntimeDefinition(), and clang::ObjCNoReturn::isImplicitNoReturn().

Retrieve the receiver type to which this message is being directed.

This routine cross-cuts all of the different kinds of message sends to determine what the underlying (statically known) type of the receiver will be; use getReceiverKind() to determine whether the message is a class or an instance method, whether it is a send to super or not, etc.

Returns:
The type of the receiver.

Definition at line 3642 of file Expr.cpp.

References Class, getClassReceiver(), getInstanceReceiver(), getReceiverKind(), getSuperType(), clang::Expr::getType(), Instance, SuperClass, and SuperInstance.

Referenced by getReceiverInterface(), and clang::Expr::isUnusedResultAWarning().

Definition at line 1328 of file ExprObjC.h.

void ObjCMessageExpr::getSelectorLocs ( SmallVectorImpl< SourceLocation > &  SelLocs) const

Definition at line 3613 of file Expr.cpp.

References getNumSelectorLocs(), and getSelectorLoc().

Definition at line 1330 of file ExprObjC.h.

References getLocStart(), getSelectorLoc(), and isImplicit().

Retrieve the location of the 'super' keyword for a class or instance message to 'super', otherwise an invalid source location.

Definition at line 1214 of file ExprObjC.h.

References getReceiverKind(), SuperClass, and SuperInstance.

Referenced by clang::Sema::checkRetainCycles(), and getReceiverRange().

Retrieve the type referred to by 'super'.

The returned type will either be an ObjCInterfaceType (for an class message to super) or an ObjCObjectPointerType that refers to a class (for an instance message to super);

Definition at line 1249 of file ExprObjC.h.

References clang::QualType::getFromOpaquePtr(), getReceiverKind(), SuperClass, and SuperInstance.

Referenced by clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr(), getReceiverType(), clang::ObjCMethodCall::getRuntimeDefinition(), and maybeAdjustInterfaceForSubscriptingCheck().

Determine whether this is an class message to either a specified class or to super.

Definition at line 1167 of file ExprObjC.h.

References Class, getReceiverKind(), and SuperClass.

isDelegateInitCall - Answers whether this message send has been tagged as a "delegate init call", i.e. a call to a method in the -init family on self from within an -init method implementation.

Definition at line 1324 of file ExprObjC.h.

Referenced by clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr().

Indicates whether the message send was implicitly generated by the implementation. If false, it was written explicitly in the source code.

Definition at line 1150 of file ExprObjC.h.

Referenced by checkForLiteralCreation(), Create(), getNumSelectorLocs(), getSelectorStartLoc(), and clang::edit::rewriteToObjCSubscriptSyntax().

Determine whether this is an instance message to either a computed object or to super.

Definition at line 1161 of file ExprObjC.h.

References getReceiverKind(), Instance, and SuperInstance.

Referenced by clang::Sema::checkRetainCycles(), clang::ObjCMethodCall::getRuntimeDefinition(), clang::ObjCNoReturn::isImplicitNoReturn(), and clang::Expr::isUnusedResultAWarning().

void clang::ObjCMessageExpr::setArg ( unsigned  Arg,
Expr ArgExpr 
) [inline]

setArg - Set the specified argument.

Definition at line 1316 of file ExprObjC.h.

References getArgs().

Definition at line 1207 of file ExprObjC.h.

References Class.

void clang::ObjCMessageExpr::setDelegateInitCall ( bool  isDelegate) [inline]

Definition at line 1325 of file ExprObjC.h.

Referenced by clang::Sema::BuildInstanceMessage().

Turn this message send into an instance message that computes the receiver object with the given expression.

Definition at line 1185 of file ExprObjC.h.

References Instance.

Definition at line 1283 of file ExprObjC.h.

Definition at line 1264 of file ExprObjC.h.

References clang::Selector::getAsOpaquePtr().

Definition at line 1357 of file ExprObjC.h.

References clang::SourceRange::getBegin(), and clang::SourceRange::getEnd().

void clang::ObjCMessageExpr::setSuper ( SourceLocation  Loc,
QualType  T,
bool  IsInstanceSuper 
) [inline]

Definition at line 1256 of file ExprObjC.h.

References clang::QualType::getAsOpaquePtr(), SuperClass, and SuperInstance.


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 1385 of file ExprObjC.h.

friend class ASTStmtWriter [friend]

Reimplemented from clang::Stmt.

Definition at line 1386 of file ExprObjC.h.


The documentation for this class was generated from the following files: