class ObjCMethodDecl

Declaration

class ObjCMethodDecl : public NamedDecl, public DeclContext { /* full declaration omitted */ };

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: - (void)setMenu:(NSMenu *)menu; - (NSMenu *)menu; Instance method that takes 2 NSView arguments: - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView; 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.

Declared at: clang/include/clang/AST/DeclObjC.h:139

Inherits from: NamedDecl, DeclContext

Member Variables

private clang::QualType MethodDeclType
Return type of this method.
private clang::TypeSourceInfo* ReturnTInfo
Type source information for the return type.
private void* ParamsAndSelLocs = nullptr
Array of ParmVarDecls for the formal parameters of this method and optionally followed by selector locations.
private unsigned int NumParams = 0
private clang::SourceLocation DeclEndLoc
List of attributes for this method declaration.
private clang::LazyDeclStmtPtr Body
The following are only used for method definitions, null otherwise.
private clang::ImplicitParamDecl* SelfDecl = nullptr
SelfDecl - Decl for the implicit self parameter. This is lazily constructed by createImplicitParams.
private clang::ImplicitParamDecl* CmdDecl = nullptr
CmdDecl - Decl for the implicit _cmd parameter. This is lazily constructed by createImplicitParams.

Inherited from DeclContext:

protected
protected FirstDecl = nullptr
protected LastDecl = nullptr

Inherited from Decl:

protected NextInContextAndBits
protected Access
protected FromASTFile
protected IdentifierNamespace
protected CacheValidAndLinkage

Method Overview

Inherited from DeclContext:

Inherited from NamedDecl:

Inherited from Decl:

Methods

static clang::ObjCMethodDecl* Create(
    clang::ASTContext& C,
    clang::SourceLocation beginLoc,
    clang::SourceLocation endLoc,
    clang::Selector SelInfo,
    clang::QualType T,
    clang::TypeSourceInfo* ReturnTInfo,
    clang::DeclContext* contextDecl,
    bool isInstance = true,
    bool isVariadic = false,
    bool isPropertyAccessor = false,
    bool isSynthesizedAccessorStub = false,
    bool isImplicitlyDeclared = false,
    bool isDefined = false,
    clang::ObjCMethodDecl::ImplementationControl
        impControl = None,
    bool HasRelatedResultType = false)

Declared at: clang/include/clang/AST/DeclObjC.h:233

Parameters

clang::ASTContext& C
clang::SourceLocation beginLoc
clang::SourceLocation endLoc
clang::Selector SelInfo
clang::QualType T
clang::TypeSourceInfo* ReturnTInfo
clang::DeclContext* contextDecl
bool isInstance = true
bool isVariadic = false
bool isPropertyAccessor = false
bool isSynthesizedAccessorStub = false
bool isImplicitlyDeclared = false
bool isDefined = false
clang::ObjCMethodDecl::ImplementationControl impControl = None
bool HasRelatedResultType = false

static clang::ObjCMethodDecl* CreateDeserialized(
    clang::ASTContext& C,
    unsigned int ID)

Declared at: clang/include/clang/AST/DeclObjC.h:242

Parameters

clang::ASTContext& C
unsigned int ID

ObjCMethodDecl(
    clang::SourceLocation beginLoc,
    clang::SourceLocation endLoc,
    clang::Selector SelInfo,
    clang::QualType T,
    clang::TypeSourceInfo* ReturnTInfo,
    clang::DeclContext* contextDecl,
    bool isInstance = true,
    bool isVariadic = false,
    bool isPropertyAccessor = false,
    bool isSynthesizedAccessorStub = false,
    bool isImplicitlyDeclared = false,
    bool isDefined = false,
    clang::ObjCMethodDecl::ImplementationControl
        impControl = None,
    bool HasRelatedResultType = false)

Declared at: clang/include/clang/AST/DeclObjC.h:172

Parameters

clang::SourceLocation beginLoc
clang::SourceLocation endLoc
clang::Selector SelInfo
clang::QualType T
clang::TypeSourceInfo* ReturnTInfo
clang::DeclContext* contextDecl
bool isInstance = true
bool isVariadic = false
bool isPropertyAccessor = false
bool isSynthesizedAccessorStub = false
bool isImplicitlyDeclared = false
bool isDefined = false
clang::ObjCMethodDecl::ImplementationControl impControl = None
bool HasRelatedResultType = false

static clang::ObjCMethodDecl* castFromDeclContext(
    const clang::DeclContext* DC)

Declared at: clang/include/clang/AST/DeclObjC.h:551

Parameters

const clang::DeclContext* DC

static clang::DeclContext* castToDeclContext(
    const clang::ObjCMethodDecl* D)

Declared at: clang/include/clang/AST/DeclObjC.h:547

Parameters

const clang::ObjCMethodDecl* D

static bool classof(const clang::Decl* D)

Declared at: clang/include/clang/AST/DeclObjC.h:544

Parameters

const clang::Decl* D

static bool classofKind(clang::Decl::Kind K)

Declared at: clang/include/clang/AST/DeclObjC.h:545

Parameters

clang::Decl::Kind K

void createImplicitParams(
    clang::ASTContext& Context,
    const clang::ObjCInterfaceDecl* ID)

Description

createImplicitParams - Used to lazily create the self and cmd implicit parameters. This must be called prior to using getSelfDecl() or getCmdDecl(). The call is ignored if the implicit parameters have already been created.

Declared at: clang/include/clang/AST/DeclObjC.h:416

Parameters

clang::ASTContext& Context
const clang::ObjCInterfaceDecl* ID

bool definedInNSObject(
    const clang::ASTContext&) const

Description

Is this method defined in the NSObject base class?

Declared at: clang/include/clang/AST/DeclObjC.h:541

Parameters

const clang::ASTContext&

const clang::ObjCPropertyDecl* findPropertyDecl(
    bool CheckOverrides = true) const

Description

Returns the property associated with this method's selector. Note that even if this particular method is not marked as a property accessor, it is still possible for it to match a property declared in a superclass. Pass \c false if you only want to check the current class.

Declared at: clang/include/clang/AST/DeclObjC.h:498

Parameters

bool CheckOverrides = true

clang::SourceLocation getBeginLoc() const

Declared at: clang/include/clang/AST/DeclObjC.h:285

clang::Stmt* getBody() const

Description

Retrieve the body of this method, if it has one.

Declared at: clang/include/clang/AST/DeclObjC.h:530

clang::ObjCMethodDecl* getCanonicalDecl()

Description

Retrieves the "canonical" declaration of the given declaration.

Declared at: clang/include/clang/AST/DeclObjC.h:244

const clang::ObjCMethodDecl* getCanonicalDecl()
    const

Declared at: clang/include/clang/AST/DeclObjC.h:245

clang::ObjCCategoryDecl* getCategory()

Description

If this method is declared or implemented in a category, return that category.

Declared at: clang/include/clang/AST/DeclObjC.h:325

const clang::ObjCCategoryDecl* getCategory() const

Declared at: clang/include/clang/AST/DeclObjC.h:326

clang::ObjCInterfaceDecl* getClassInterface()

Declared at: clang/include/clang/AST/DeclObjC.h:318

const clang::ObjCInterfaceDecl*
getClassInterface() const

Declared at: clang/include/clang/AST/DeclObjC.h:319

clang::ImplicitParamDecl* getCmdDecl() const

Declared at: clang/include/clang/AST/DeclObjC.h:425

clang::CompoundStmt* getCompoundBody()

Declared at: clang/include/clang/AST/DeclObjC.h:534

clang::SourceLocation getDeclaratorEndLoc() const

Description

Returns the location where the declarator ends. It will be the location of ';' for a method declaration and the location of '{' for a method definition.

Declared at: clang/include/clang/AST/DeclObjC.h:282

clang::SourceLocation getEndLoc() const

Declared at: clang/include/clang/AST/DeclObjC.h:286

clang::ObjCMethodDecl::ImplementationControl
getImplementationControl() const

Declared at: clang/include/clang/AST/DeclObjC.h:505

clang::ObjCMethodFamily getMethodFamily() const

Description

Determines the family of this method.

Declared at: clang/include/clang/AST/DeclObjC.h:429

clang::ObjCMethodDecl* getNextRedeclarationImpl()

Description

A definition will return its interface declaration. An interface declaration will return its definition. Otherwise it will return itself.

Declared at: clang/include/clang/AST/DeclObjC.h:226

unsigned int getNumSelectorLocs() const

Declared at: clang/include/clang/AST/DeclObjC.h:309

unsigned int getNumStoredSelLocs() const

Description

Get the number of stored selector identifiers locations. No locations will be stored if HasStandardSelLocs is true.

Declared at: clang/include/clang/AST/DeclObjC.h:213

clang::Decl::ObjCDeclQualifier
getObjCDeclQualifier() const

Declared at: clang/include/clang/AST/DeclObjC.h:249

void getOverriddenMethods(
    SmallVectorImpl<const clang::ObjCMethodDecl*>&
        Overridden) const

Description

Return overridden methods for the given \p Method. An ObjC method is considered to override any method in the class's base classes (and base's categories), its protocols, or its categories' protocols, that has the same selector and is of the same kind (class or instance). A method in an implementation is not considered as overriding the same method in the interface or its categories.

Declared at: clang/include/clang/AST/DeclObjC.h:478

Parameters

SmallVectorImpl<const clang::ObjCMethodDecl*>& Overridden

const clang::ParmVarDecl* getParamDecl(
    unsigned int Idx) const

Declared at: clang/include/clang/AST/DeclObjC.h:385

Parameters

unsigned int Idx

clang::ParmVarDecl* getParamDecl(unsigned int Idx)

Declared at: clang/include/clang/AST/DeclObjC.h:381

Parameters

unsigned int Idx

const clang::ParmVarDecl* const* getParams() const

Declared at: clang/include/clang/AST/DeclObjC.h:207

clang::ParmVarDecl** getParams()

Description

Get a pointer to the stored selector identifiers locations array. No locations will be stored if HasStandardSelLocs is true.

Declared at: clang/include/clang/AST/DeclObjC.h:204

clang::QualType getReturnType() const

Declared at: clang/include/clang/AST/DeclObjC.h:332

clang::TypeSourceInfo* getReturnTypeSourceInfo()
    const

Declared at: clang/include/clang/AST/DeclObjC.h:346

clang::SourceRange getReturnTypeSourceRange()
    const

Declared at: clang/include/clang/AST/DeclObjC.h:334

clang::SelectorLocationsKind getSelLocsKind()
    const

Declared at: clang/include/clang/AST/DeclObjC.h:181

clang::Selector getSelector() const

Declared at: clang/include/clang/AST/DeclObjC.h:330

clang::SourceLocation getSelectorLoc(
    unsigned int Index) const

Declared at: clang/include/clang/AST/DeclObjC.h:297

Parameters

unsigned int Index

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

Declared at: clang/include/clang/AST/DeclObjC.h:307

Parameters

SmallVectorImpl<clang::SourceLocation>& SelLocs

clang::SourceLocation getSelectorStartLoc() const

Declared at: clang/include/clang/AST/DeclObjC.h:291

clang::ImplicitParamDecl* getSelfDecl() const

Declared at: clang/include/clang/AST/DeclObjC.h:423

clang::QualType getSelfType(
    clang::ASTContext& Context,
    const clang::ObjCInterfaceDecl* OID,
    bool& selfIsPseudoStrong,
    bool& selfIsConsumed) const

Declared at: clang/include/clang/AST/DeclObjC.h:420

Parameters

clang::ASTContext& Context
const clang::ObjCInterfaceDecl* OID
bool& selfIsPseudoStrong
bool& selfIsConsumed

Returns

the type for \c self and set

clang::QualType getSendResultType() const

Description

Determine the type of an expression that sends a message to this function. This replaces the type parameters with the types they would get if the receiver was parameterless (e.g. it may replace the type parameter with 'id').

Declared at: clang/include/clang/AST/DeclObjC.h:340

clang::QualType getSendResultType(
    clang::QualType receiverType) const

Description

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

Declared at: clang/include/clang/AST/DeclObjC.h:344

Parameters

clang::QualType receiverType

clang::SourceRange getSourceRange() const

Description

Source range that this declaration covers.

Declared at: clang/include/clang/AST/DeclObjC.h:287

const clang::SourceLocation* getStoredSelLocs()
    const

Declared at: clang/include/clang/AST/DeclObjC.h:198

clang::SourceLocation* getStoredSelLocs()

Description

Get a pointer to the stored selector identifiers locations array. No locations will be stored if HasStandardSelLocs is true.

Declared at: clang/include/clang/AST/DeclObjC.h:195

bool hasBody() const

Description

Determine whether this method has a body.

Declared at: clang/include/clang/AST/DeclObjC.h:527

bool hasParamDestroyedInCallee() const

Description

True if the method has a parameter that's destroyed in the callee.

Declared at: clang/include/clang/AST/DeclObjC.h:491

bool hasRedeclaration() const

Description

True if redeclared in the same interface.

Declared at: clang/include/clang/AST/DeclObjC.h:274

bool hasRelatedResultType() const

Description

Determine whether this method has a result type that is related to the message receiver's type.

Declared at: clang/include/clang/AST/DeclObjC.h:259

bool hasSkippedBody() const

Description

True if the method was a definition but its body was skipped.

Declared at: clang/include/clang/AST/DeclObjC.h:482

bool hasStandardSelLocs() const

Declared at: clang/include/clang/AST/DeclObjC.h:189

bool isClassMethod() const

Declared at: clang/include/clang/AST/DeclObjC.h:439

bool isDefined() const

Declared at: clang/include/clang/AST/DeclObjC.h:457

bool isDesignatedInitializerForTheInterface(
    const clang::ObjCMethodDecl** InitMethod =
        nullptr) const

Description

Returns true if the method selector resolves to a designated initializer in the class's interface.

Declared at: clang/include/clang/AST/DeclObjC.h:523

Parameters

const clang::ObjCMethodDecl** InitMethod = nullptr
if non-null and the function returns true, it receives the method declaration that was marked with the designated initializer attribute.

bool isDirectMethod() const

Description

True if the method is tagged as objc_direct

Declared at: clang/include/clang/AST/DeclObjC.h:488

bool isInstanceMethod() const

Declared at: clang/include/clang/AST/DeclObjC.h:431

bool isOptional() const

Declared at: clang/include/clang/AST/DeclObjC.h:509

bool isOverriding() const

Description

Whether this method overrides any other in the class hierarchy. A method is said to override any method in the class's base classes, its protocols, or its categories' protocols, that has the same selector and is of the same kind (class or instance). A method in an implementation is not considered as overriding the same method in the interface or its categories.

Declared at: clang/include/clang/AST/DeclObjC.h:467

bool isPropertyAccessor() const

Declared at: clang/include/clang/AST/DeclObjC.h:441

bool isRedeclaration() const

Description

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

Declared at: clang/include/clang/AST/DeclObjC.h:269

bool isSynthesizedAccessorStub() const

Declared at: clang/include/clang/AST/DeclObjC.h:449

bool isThisDeclarationADefinition() const

Description

Returns whether this specific method is a definition.

Declared at: clang/include/clang/AST/DeclObjC.h:538

bool isThisDeclarationADesignatedInitializer()
    const

Description

Returns true if this specific method declaration is marked with the designated initializer attribute.

Declared at: clang/include/clang/AST/DeclObjC.h:515

bool isVariadic() const

Declared at: clang/include/clang/AST/DeclObjC.h:436

clang::ObjCMethodDecl::param_iterator
param_begin()

Declared at: clang/include/clang/AST/DeclObjC.h:365

clang::ObjCMethodDecl::param_const_iterator
param_begin() const

Declared at: clang/include/clang/AST/DeclObjC.h:357

clang::ObjCMethodDecl::param_const_iterator
param_end() const

Declared at: clang/include/clang/AST/DeclObjC.h:361

clang::ObjCMethodDecl::param_iterator param_end()

Declared at: clang/include/clang/AST/DeclObjC.h:366

unsigned int param_size() const

Declared at: clang/include/clang/AST/DeclObjC.h:350

clang::ObjCMethodDecl::param_type_iterator
param_type_begin() const

Declared at: clang/include/clang/AST/DeclObjC.h:404

clang::ObjCMethodDecl::param_type_iterator
param_type_end() const

Declared at: clang/include/clang/AST/DeclObjC.h:408

ArrayRef<clang::ParmVarDecl*> parameters() const

Declared at: clang/include/clang/AST/DeclObjC.h:376

clang::ObjCMethodDecl::param_const_iterator
sel_param_end() const

Declared at: clang/include/clang/AST/DeclObjC.h:370

void setAsRedeclaration(
    const clang::ObjCMethodDecl* PrevMethod)

Declared at: clang/include/clang/AST/DeclObjC.h:271

Parameters

const clang::ObjCMethodDecl* PrevMethod

void setBody(clang::Stmt* B)

Declared at: clang/include/clang/AST/DeclObjC.h:535

Parameters

clang::Stmt* B

void setCmdDecl(clang::ImplicitParamDecl* CD)

Declared at: clang/include/clang/AST/DeclObjC.h:426

Parameters

clang::ImplicitParamDecl* CD

void setDeclImplementation(
    clang::ObjCMethodDecl::ImplementationControl
        ic)

Declared at: clang/include/clang/AST/DeclObjC.h:501

Parameters

clang::ObjCMethodDecl::ImplementationControl ic

void setDefined(bool isDefined)

Declared at: clang/include/clang/AST/DeclObjC.h:458

Parameters

bool isDefined

void setHasRedeclaration(bool HRD) const

Declared at: clang/include/clang/AST/DeclObjC.h:275

Parameters

bool HRD

void setHasSkippedBody(bool Skipped = true)

Declared at: clang/include/clang/AST/DeclObjC.h:483

Parameters

bool Skipped = true

void setInstanceMethod(bool isInst)

Declared at: clang/include/clang/AST/DeclObjC.h:432

Parameters

bool isInst

void setIsRedeclaration(bool RD)

Declared at: clang/include/clang/AST/DeclObjC.h:270

Parameters

bool RD

void setLazyBody(uint64_t Offset)

Declared at: clang/include/clang/AST/DeclObjC.h:532

Parameters

uint64_t Offset

void setMethodParams(
    clang::ASTContext& C,
    ArrayRef<clang::ParmVarDecl*> Params,
    ArrayRef<clang::SourceLocation> SelLocs =
        llvm::None)

Description

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

Declared at: clang/include/clang/AST/DeclObjC.h:392

Parameters

clang::ASTContext& C
ArrayRef<clang::ParmVarDecl*> Params
ArrayRef<clang::SourceLocation> SelLocs = llvm::None

void setObjCDeclQualifier(
    clang::Decl::ObjCDeclQualifier QV)

Declared at: clang/include/clang/AST/DeclObjC.h:253

Parameters

clang::Decl::ObjCDeclQualifier QV

void setOverriding(bool IsOver)

Declared at: clang/include/clang/AST/DeclObjC.h:468

Parameters

bool IsOver

void setParamsAndSelLocs(
    clang::ASTContext& C,
    ArrayRef<clang::ParmVarDecl*> Params,
    ArrayRef<clang::SourceLocation> SelLocs)

Declared at: clang/include/clang/AST/DeclObjC.h:219

Parameters

clang::ASTContext& C
ArrayRef<clang::ParmVarDecl*> Params
ArrayRef<clang::SourceLocation> SelLocs

void setPropertyAccessor(bool isAccessor)

Declared at: clang/include/clang/AST/DeclObjC.h:445

Parameters

bool isAccessor

void setRelatedResultType(bool RRT = true)

Description

Note whether this method has a related result type.

Declared at: clang/include/clang/AST/DeclObjC.h:264

Parameters

bool RRT = true

void setReturnType(clang::QualType T)

Declared at: clang/include/clang/AST/DeclObjC.h:333

Parameters

clang::QualType T

void setReturnTypeSourceInfo(
    clang::TypeSourceInfo* TInfo)

Declared at: clang/include/clang/AST/DeclObjC.h:347

Parameters

clang::TypeSourceInfo* TInfo

void setSelLocsKind(
    clang::SelectorLocationsKind Kind)

Declared at: clang/include/clang/AST/DeclObjC.h:185

Parameters

clang::SelectorLocationsKind Kind

void setSelfDecl(clang::ImplicitParamDecl* SD)

Declared at: clang/include/clang/AST/DeclObjC.h:424

Parameters

clang::ImplicitParamDecl* SD

void setSynthesizedAccessorStub(
    bool isSynthesizedAccessorStub)

Declared at: clang/include/clang/AST/DeclObjC.h:453

Parameters

bool isSynthesizedAccessorStub

void setVariadic(bool isVar)

Declared at: clang/include/clang/AST/DeclObjC.h:437

Parameters

bool isVar