clang API Documentation

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

#include <DeclObjC.h>

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

List of all members.

Public Types

enum  ImplementationControl { None, Required, Optional }
typedef const ParmVarDecl *const * param_const_iterator
typedef ParmVarDecl *const * param_iterator
typedef std::const_mem_fun_t
< QualType, ParmVarDecl
deref_fun
typedef llvm::mapped_iterator
< param_const_iterator,
deref_fun
arg_type_iterator

Public Member Functions

virtual ObjCMethodDeclgetCanonicalDecl ()
 Retrieves the "canonical" declaration of the given declaration.
const ObjCMethodDeclgetCanonicalDecl () const
ObjCDeclQualifier getObjCDeclQualifier () const
void setObjCDeclQualifier (ObjCDeclQualifier QV)
bool hasRelatedResultType () const
 Determine whether this method has a result type that is related to the message receiver's type.
void SetRelatedResultType (bool RRT=true)
 Note whether this method has a related result type.
bool isRedeclaration () const
 True if this is a method redeclaration in the same interface.
void setAsRedeclaration (const ObjCMethodDecl *PrevMethod)
SourceLocation getLocStart () const
SourceLocation getLocEnd () const
void setEndLoc (SourceLocation Loc)
virtual SourceRange getSourceRange () const
 Source range that this declaration covers.
SourceLocation getSelectorStartLoc () const
SourceLocation getSelectorLoc (unsigned Index) const
void getSelectorLocs (SmallVectorImpl< SourceLocation > &SelLocs) const
unsigned getNumSelectorLocs () const
ObjCInterfaceDeclgetClassInterface ()
const ObjCInterfaceDeclgetClassInterface () const
Selector getSelector () const
QualType getResultType () const
void setResultType (QualType T)
QualType getSendResultType () const
 Determine the type of an expression that sends a message to this function.
TypeSourceInfogetResultTypeSourceInfo () const
void setResultTypeSourceInfo (TypeSourceInfo *TInfo)
unsigned param_size () const
param_const_iterator param_begin () const
param_const_iterator param_end () const
param_iterator param_begin ()
param_iterator param_end ()
param_const_iterator sel_param_end () const
void setMethodParams (ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=ArrayRef< SourceLocation >())
 Sets the method's parameters and selector source locations. If the method is implicit (not coming from source)
arg_type_iterator arg_type_begin () const
arg_type_iterator arg_type_end () const
void createImplicitParams (ASTContext &Context, const ObjCInterfaceDecl *ID)
ImplicitParamDeclgetSelfDecl () const
void setSelfDecl (ImplicitParamDecl *SD)
ImplicitParamDeclgetCmdDecl () const
void setCmdDecl (ImplicitParamDecl *CD)
ObjCMethodFamily getMethodFamily () const
 Determines the family of this method.
bool isInstanceMethod () const
void setInstanceMethod (bool isInst)
bool isVariadic () const
void setVariadic (bool isVar)
bool isClassMethod () const
bool isSynthesized () const
void setSynthesized (bool isSynth)
bool isDefined () const
void setDefined (bool isDefined)
void setDeclImplementation (ImplementationControl ic)
ImplementationControl getImplementationControl () const
virtual StmtgetBody () const
CompoundStmtgetCompoundBody ()
void setBody (Stmt *B)
bool isThisDeclarationADefinition () const
 Returns whether this specific method is a definition.

Static Public Member Functions

static ObjCMethodDeclCreate (ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ResultTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isSynthesized=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
static ObjCMethodDeclCreateDeserialized (ASTContext &C, unsigned ID)
static bool classof (const Decl *D)
static bool classof (const ObjCMethodDecl *D)
static bool classofKind (Kind K)
static DeclContextcastToDeclContext (const ObjCMethodDecl *D)
static ObjCMethodDeclcastFromDeclContext (const DeclContext *DC)

Friends

class ASTDeclReader
class ASTDeclWriter

Detailed Description

ObjCMethodDecl - Represents an instance or class method declaration. ObjC methods can be declared within 4 contexts: class interfaces, categories, protocols, and class implementations. While C++ member functions leverage C syntax, Objective-C method syntax is modeled after Smalltalk (using colons to specify argument types/expressions). Here are some brief examples:

Setter/getter instance methods:

Instance method that takes 2 NSView arguments:

Getter class method: + (NSMenu *)defaultMenu;

A selector represents a unique name for a method. The selector names for the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu.

Definition at line 112 of file DeclObjC.h.


Member Typedef Documentation

Definition at line 362 of file DeclObjC.h.

typedef std::const_mem_fun_t<QualType, ParmVarDecl> clang::ObjCMethodDecl::deref_fun

Definition at line 360 of file DeclObjC.h.

Definition at line 339 of file DeclObjC.h.

Definition at line 340 of file DeclObjC.h.


Member Enumeration Documentation

Enumerator:
None 
Required 
Optional 

Definition at line 114 of file DeclObjC.h.


Member Function Documentation

arg_type_iterator clang::ObjCMethodDecl::arg_type_begin ( ) const [inline]

Definition at line 364 of file DeclObjC.h.

References clang::ValueDecl::getType(), and param_begin().

Referenced by getMethodFamily().

arg_type_iterator clang::ObjCMethodDecl::arg_type_end ( ) const [inline]

Definition at line 367 of file DeclObjC.h.

References clang::ValueDecl::getType(), and param_end().

static ObjCMethodDecl* clang::ObjCMethodDecl::castFromDeclContext ( const DeclContext DC) [inline, static]

Reimplemented from clang::Decl.

Definition at line 422 of file DeclObjC.h.

static DeclContext* clang::ObjCMethodDecl::castToDeclContext ( const ObjCMethodDecl D) [inline, static]

Definition at line 419 of file DeclObjC.h.

static bool clang::ObjCMethodDecl::classof ( const Decl D) [inline, static]

Reimplemented from clang::NamedDecl.

Definition at line 416 of file DeclObjC.h.

References classofKind(), and clang::Decl::getKind().

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

Definition at line 417 of file DeclObjC.h.

static bool clang::ObjCMethodDecl::classofKind ( Kind  K) [inline, static]

Reimplemented from clang::NamedDecl.

Definition at line 418 of file DeclObjC.h.

Referenced by classof().

ObjCMethodDecl * ObjCMethodDecl::Create ( ASTContext C,
SourceLocation  beginLoc,
SourceLocation  endLoc,
Selector  SelInfo,
QualType  T,
TypeSourceInfo ResultTInfo,
DeclContext contextDecl,
bool  isInstance = true,
bool  isVariadic = false,
bool  isSynthesized = false,
bool  isImplicitlyDeclared = false,
bool  isDefined = false,
ImplementationControl  impControl = None,
bool  HasRelatedResultType = false 
) [static]
ObjCMethodDecl * ObjCMethodDecl::CreateDeserialized ( ASTContext C,
unsigned  ID 
) [static]

Definition at line 409 of file DeclObjC.cpp.

References clang::Decl::AllocateDeserializedDecl().

void ObjCMethodDecl::createImplicitParams ( ASTContext Context,
const ObjCInterfaceDecl ID 
)
virtual Stmt* clang::ObjCMethodDecl::getBody ( ) const [inline, virtual]

getBody - If this Decl represents a declaration for a body of code, such as a function or method definition, this method returns the top-level Stmt* of that body. Otherwise this method returns null.

Reimplemented from clang::Decl.

Definition at line 406 of file DeclObjC.h.

Referenced by checkObjCDealloc(), clang::CodeGen::CodeGenModule::EmitTopLevelDecl(), clang::CodeGen::CodeGenFunction::GenerateObjCMethod(), clang::idx::ASTVisitor< ImplClass >::VisitObjCMethodDecl(), and clang::ASTDeclWriter::VisitObjCMethodDecl().

ObjCMethodDecl * ObjCMethodDecl::getCanonicalDecl ( ) [virtual]

Retrieves the "canonical" declaration of the given declaration.

Reimplemented from clang::Decl.

Definition at line 499 of file DeclObjC.cpp.

References clang::Decl::getDeclContext(), getSelector(), isInstanceMethod(), and isRedeclaration().

Referenced by getCanonicalDecl().

const ObjCMethodDecl* clang::ObjCMethodDecl::getCanonicalDecl ( ) const [inline]

Reimplemented from clang::Decl.

Definition at line 263 of file DeclObjC.h.

References getCanonicalDecl().

ObjCInterfaceDecl * ObjCMethodDecl::getClassInterface ( )
const ObjCInterfaceDecl* clang::ObjCMethodDecl::getClassInterface ( ) const [inline]

Definition at line 319 of file DeclObjC.h.

References getClassInterface().

ImplicitParamDecl* clang::ObjCMethodDecl::getCmdDecl ( ) const [inline]
CompoundStmt* clang::ObjCMethodDecl::getCompoundBody ( ) [inline]

Definition at line 409 of file DeclObjC.h.

Referenced by cleanupDeallocOrFinalize().

ImplementationControl clang::ObjCMethodDecl::getImplementationControl ( ) const [inline]
SourceLocation clang::ObjCMethodDecl::getLocEnd ( ) const [inline]
SourceLocation clang::ObjCMethodDecl::getLocStart ( ) const [inline]
ObjCMethodFamily ObjCMethodDecl::getMethodFamily ( ) const
unsigned clang::ObjCMethodDecl::getNumSelectorLocs ( ) const [inline]
ObjCDeclQualifier clang::ObjCMethodDecl::getObjCDeclQualifier ( ) const [inline]
QualType clang::ObjCMethodDecl::getResultType ( ) const [inline]
TypeSourceInfo* clang::ObjCMethodDecl::getResultTypeSourceInfo ( ) const [inline]
Selector clang::ObjCMethodDecl::getSelector ( ) const [inline]
SourceLocation clang::ObjCMethodDecl::getSelectorLoc ( unsigned  Index) const [inline]
void ObjCMethodDecl::getSelectorLocs ( SmallVectorImpl< SourceLocation > &  SelLocs) const

Definition at line 437 of file DeclObjC.cpp.

References getNumSelectorLocs(), and getSelectorLoc().

Referenced by clang::ASTNodeImporter::VisitObjCMethodDecl().

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

Definition at line 291 of file DeclObjC.h.

References getLocStart(), getSelectorLoc(), and clang::Decl::isImplicit().

Referenced by cleanupDeallocOrFinalize().

ImplicitParamDecl* clang::ObjCMethodDecl::getSelfDecl ( ) const [inline]
QualType clang::ObjCMethodDecl::getSendResultType ( ) const [inline]

Determine the type of an expression that sends a message to this function.

Definition at line 330 of file DeclObjC.h.

References clang::Decl::getASTContext(), clang::QualType::getNonLValueExprType(), and getResultType().

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

virtual SourceRange clang::ObjCMethodDecl::getSourceRange ( ) const [inline, virtual]

Source range that this declaration covers.

Reimplemented from clang::Decl.

Definition at line 287 of file DeclObjC.h.

References clang::Decl::getLocation().

Referenced by clang::Sema::CheckMessageArgumentTypes(), cleanupDeallocOrFinalize(), and GCRewriteFinalize().

bool clang::ObjCMethodDecl::hasRelatedResultType ( ) const [inline]
bool clang::ObjCMethodDecl::isClassMethod ( ) const [inline]
bool clang::ObjCMethodDecl::isDefined ( ) const [inline]
bool clang::ObjCMethodDecl::isInstanceMethod ( ) const [inline]
bool clang::ObjCMethodDecl::isRedeclaration ( ) const [inline]

True if this is a method redeclaration in the same interface.

Definition at line 280 of file DeclObjC.h.

Referenced by getCanonicalDecl().

bool clang::ObjCMethodDecl::isSynthesized ( ) const [inline]
bool clang::ObjCMethodDecl::isThisDeclarationADefinition ( ) const [inline]

Returns whether this specific method is a definition.

Definition at line 413 of file DeclObjC.h.

bool clang::ObjCMethodDecl::isVariadic ( ) const [inline]
param_const_iterator clang::ObjCMethodDecl::param_begin ( ) const [inline]
param_iterator clang::ObjCMethodDecl::param_begin ( ) [inline]

Definition at line 343 of file DeclObjC.h.

param_const_iterator clang::ObjCMethodDecl::param_end ( ) const [inline]
param_iterator clang::ObjCMethodDecl::param_end ( ) [inline]

Definition at line 344 of file DeclObjC.h.

unsigned clang::ObjCMethodDecl::param_size ( ) const [inline]
param_const_iterator clang::ObjCMethodDecl::sel_param_end ( ) const [inline]
void ObjCMethodDecl::setAsRedeclaration ( const ObjCMethodDecl PrevMethod)
void clang::ObjCMethodDecl::setBody ( Stmt B) [inline]

Definition at line 410 of file DeclObjC.h.

Referenced by clang::ASTDeclReader::VisitObjCMethodDecl().

void clang::ObjCMethodDecl::setCmdDecl ( ImplicitParamDecl CD) [inline]

Definition at line 380 of file DeclObjC.h.

Referenced by createImplicitParams(), and clang::ASTDeclReader::VisitObjCMethodDecl().

void clang::ObjCMethodDecl::setDeclImplementation ( ImplementationControl  ic) [inline]

Definition at line 399 of file DeclObjC.h.

Referenced by clang::ASTDeclReader::VisitObjCMethodDecl().

void clang::ObjCMethodDecl::setDefined ( bool  isDefined) [inline]
void clang::ObjCMethodDecl::setEndLoc ( SourceLocation  Loc) [inline]

Definition at line 286 of file DeclObjC.h.

Referenced by clang::ASTDeclReader::VisitObjCMethodDecl().

void clang::ObjCMethodDecl::setInstanceMethod ( bool  isInst) [inline]

Definition at line 386 of file DeclObjC.h.

Referenced by clang::ASTDeclReader::VisitObjCMethodDecl().

void ObjCMethodDecl::setMethodParams ( ASTContext C,
ArrayRef< ParmVarDecl * >  Params,
ArrayRef< SourceLocation SelLocs = ArrayRef<SourceLocation>() 
)

Sets the method's parameters and selector source locations. If the method is implicit (not coming from source)

  • SelLocs is ignored.

Definition at line 443 of file DeclObjC.cpp.

References getSelector(), clang::hasStandardSelectorLocs(), clang::Decl::isImplicit(), and clang::SelLoc_NonStandard.

Referenced by clang::Sema::ActOnMethodDeclaration(), clang::Sema::ProcessPropertyDecl(), and clang::ASTNodeImporter::VisitObjCMethodDecl().

void clang::ObjCMethodDecl::setObjCDeclQualifier ( ObjCDeclQualifier  QV) [inline]
void clang::ObjCMethodDecl::SetRelatedResultType ( bool  RRT = true) [inline]

Note whether this method has a related result type.

Definition at line 277 of file DeclObjC.h.

Referenced by clang::Sema::ActOnMethodDeclaration(), and clang::ASTDeclReader::VisitObjCMethodDecl().

void clang::ObjCMethodDecl::setResultType ( QualType  T) [inline]

Definition at line 326 of file DeclObjC.h.

Referenced by clang::ASTDeclReader::VisitObjCMethodDecl().

void clang::ObjCMethodDecl::setResultTypeSourceInfo ( TypeSourceInfo TInfo) [inline]

Definition at line 335 of file DeclObjC.h.

Referenced by clang::ASTDeclReader::VisitObjCMethodDecl().

void clang::ObjCMethodDecl::setSelfDecl ( ImplicitParamDecl SD) [inline]

Definition at line 378 of file DeclObjC.h.

Referenced by createImplicitParams(), and clang::ASTDeclReader::VisitObjCMethodDecl().

void clang::ObjCMethodDecl::setSynthesized ( bool  isSynth) [inline]
void clang::ObjCMethodDecl::setVariadic ( bool  isVar) [inline]

Definition at line 388 of file DeclObjC.h.

Referenced by clang::ASTDeclReader::VisitObjCMethodDecl().


Friends And Related Function Documentation

friend class ASTDeclReader [friend]

Reimplemented from clang::Decl.

Definition at line 426 of file DeclObjC.h.

friend class ASTDeclWriter [friend]

Reimplemented from clang::Decl.

Definition at line 427 of file DeclObjC.h.


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