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 receiver of 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.
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)
SourceRange getSourceRange () 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 (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 (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 (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 (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)
static bool classof (const ObjCMessageExpr *)

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 867 of file ExprObjC.h.


Member Typedef Documentation

Definition at line 1358 of file ExprObjC.h.

Definition at line 1359 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 1007 of file ExprObjC.h.


Member Function Documentation

arg_iterator clang::ObjCMessageExpr::arg_begin ( ) [inline]

Definition at line 1361 of file ExprObjC.h.

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

const_arg_iterator clang::ObjCMessageExpr::arg_begin ( ) const [inline]

Definition at line 1365 of file ExprObjC.h.

arg_iterator clang::ObjCMessageExpr::arg_end ( ) [inline]

Definition at line 1362 of file ExprObjC.h.

References NumArgs.

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

const_arg_iterator clang::ObjCMessageExpr::arg_end ( ) const [inline]

Definition at line 1368 of file ExprObjC.h.

References NumArgs.

Stmt::child_range ObjCMessageExpr::children ( )

Reimplemented from clang::Stmt.

Definition at line 3399 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 1350 of file ExprObjC.h.

References clang::Stmt::getStmtClass().

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

Definition at line 1353 of file ExprObjC.h.

ObjCMessageExpr * ObjCMessageExpr::Create ( 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.
LBracThe 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.
NumArgsThe number of arguments.
RBracLocThe location of the closing square bracket ']'.

Definition at line 2830 of file Expr.cpp.

References isImplicit().

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

ObjCMessageExpr * ObjCMessageExpr::Create ( 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.
LBracThe 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.
NumArgsThe number of arguments.
RBracLocThe location of the closing square bracket ']'.

Definition at line 2855 of file Expr.cpp.

References isImplicit().

ObjCMessageExpr * ObjCMessageExpr::Create ( 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.
LBracThe 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.
NumArgsThe number of arguments.
RBracLocThe location of the closing square bracket ']'.

Definition at line 2878 of file Expr.cpp.

References isImplicit().

ObjCMessageExpr * ObjCMessageExpr::CreateEmpty ( 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 2901 of file Expr.cpp.

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

Definition at line 1296 of file ExprObjC.h.

References Arg.

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

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

Definition at line 1284 of file ExprObjC.h.

Referenced by children().

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

Definition at line 1287 of file ExprObjC.h.

QualType clang::ObjCMessageExpr::getClassReceiver ( ) const [inline]

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

Definition at line 1188 of file ExprObjC.h.

Referenced by AddObjCExpressionResults(), clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr(), and getReceiverInterface().

TypeSourceInfo* clang::ObjCMessageExpr::getClassReceiverTypeInfo ( ) const [inline]

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

Definition at line 1197 of file ExprObjC.h.

Referenced by getReceiverRange().

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

Definition at line 1175 of file ExprObjC.h.

SourceLocation clang::ObjCMessageExpr::getLeftLoc ( ) const [inline]

Definition at line 1312 of file ExprObjC.h.

const ObjCMethodDecl* clang::ObjCMessageExpr::getMethodDecl ( ) const [inline]
ObjCMethodDecl* clang::ObjCMessageExpr::getMethodDecl ( ) [inline]

Definition at line 1261 of file ExprObjC.h.

ObjCMethodFamily clang::ObjCMessageExpr::getMethodFamily ( ) const [inline]
unsigned clang::ObjCMessageExpr::getNumArgs ( ) const [inline]
unsigned clang::ObjCMessageExpr::getNumSelectorLocs ( ) const [inline]

Definition at line 1333 of file ExprObjC.h.

References clang::Selector::getNumArgs(), and clang::Selector::isUnarySelector().

Referenced by getSelectorLocs().

ObjCInterfaceDecl * ObjCMessageExpr::getReceiverInterface ( ) const

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 2958 of file Expr.cpp.

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

Referenced by checkForLiteralCreation(), and clang::ento::ObjCMessage::getReceiverInterface().

ReceiverKind clang::ObjCMessageExpr::getReceiverKind ( ) const [inline]
SourceRange ObjCMessageExpr::getReceiverRange ( ) const
SourceLocation clang::ObjCMessageExpr::getRightLoc ( ) const [inline]

Definition at line 1313 of file ExprObjC.h.

Selector ObjCMessageExpr::getSelector ( ) const
SourceLocation clang::ObjCMessageExpr::getSelectorLoc ( unsigned  Index) const [inline]

Definition at line 1320 of file ExprObjC.h.

References clang::getStandardSelectorLoc(), Index, and clang::SelLoc_StandardWithSpace.

Referenced by getSelectorLocs().

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

Definition at line 2929 of file Expr.cpp.

References getNumSelectorLocs(), and getSelectorLoc().

SourceLocation clang::ObjCMessageExpr::getSelectorStartLoc ( ) const [inline]

Definition at line 1315 of file ExprObjC.h.

References clang::Stmt::getLocStart().

SourceRange clang::ObjCMessageExpr::getSourceRange ( ) const [inline]
SourceLocation clang::ObjCMessageExpr::getSuperLoc ( ) const [inline]

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

Definition at line 1210 of file ExprObjC.h.

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

QualType clang::ObjCMessageExpr::getSuperType ( ) const [inline]

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 1234 of file ExprObjC.h.

References clang::QualType::getFromOpaquePtr().

Referenced by clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr(), and getReceiverInterface().

bool clang::ObjCMessageExpr::isClassMessage ( ) const [inline]

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

Definition at line 1161 of file ExprObjC.h.

bool clang::ObjCMessageExpr::isDelegateInitCall ( ) const [inline]

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 1309 of file ExprObjC.h.

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

bool clang::ObjCMessageExpr::isImplicit ( ) const [inline]

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

Definition at line 1144 of file ExprObjC.h.

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

bool clang::ObjCMessageExpr::isInstanceMessage ( ) const [inline]

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

Definition at line 1155 of file ExprObjC.h.

Referenced by clang::Sema::checkRetainCycles(), clang::ento::ObjCMessage::isInstanceMessage(), and clang::Expr::isUnusedResultAWarning().

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

setArg - Set the specified argument.

Definition at line 1301 of file ExprObjC.h.

References Arg.

void clang::ObjCMessageExpr::setClassReceiver ( TypeSourceInfo TSInfo) [inline]

Definition at line 1203 of file ExprObjC.h.

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

Definition at line 1310 of file ExprObjC.h.

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

void clang::ObjCMessageExpr::setInstanceReceiver ( Expr rec) [inline]

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

Definition at line 1181 of file ExprObjC.h.

void clang::ObjCMessageExpr::setMethodDecl ( ObjCMethodDecl MD) [inline]

Definition at line 1268 of file ExprObjC.h.

void clang::ObjCMessageExpr::setSelector ( Selector  S) [inline]

Definition at line 1249 of file ExprObjC.h.

References clang::Selector::getAsOpaquePtr().

void clang::ObjCMessageExpr::setSourceRange ( SourceRange  R) [inline]

Definition at line 1342 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 1241 of file ExprObjC.h.

References clang::QualType::getAsOpaquePtr().


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 1372 of file ExprObjC.h.

friend class ASTStmtWriter [friend]

Reimplemented from clang::Stmt.

Definition at line 1373 of file ExprObjC.h.


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