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 llvm::iterator_range
< param_iterator
param_range
typedef llvm::iterator_range
< param_const_iterator
param_const_range
typedef std::const_mem_fun_t
< QualType, ParmVarDecl
deref_fun
typedef llvm::mapped_iterator
< param_const_iterator,
deref_fun
param_type_iterator

Public Member Functions

ObjCMethodDeclgetCanonicalDecl () override
 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 getDeclaratorEndLoc () const
 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.
SourceLocation getLocStart () const LLVM_READONLY
SourceLocation getLocEnd () const LLVM_READONLY
SourceRange getSourceRange () const override LLVM_READONLY
 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 getReturnType () const
void setReturnType (QualType T)
SourceRange getReturnTypeSourceRange () const
QualType getSendResultType () const
 Determine the type of an expression that sends a message to this function.
TypeSourceInfogetReturnTypeSourceInfo () const
void setReturnTypeSourceInfo (TypeSourceInfo *TInfo)
unsigned param_size () const
param_range params ()
param_const_range params () 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
ArrayRef< ParmVarDecl * > parameters () const
void setMethodParams (ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
 Sets the method's parameters and selector source locations. If the method is implicit (not coming from source) SelLocs is ignored.
param_type_iterator param_type_begin () const
param_type_iterator param_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 isPropertyAccessor () const
void setPropertyAccessor (bool isAccessor)
bool isDefined () const
void setDefined (bool isDefined)
bool isOverriding () const
 Whether this method overrides any other in the class hierarchy.
void setOverriding (bool isOverriding)
void getOverriddenMethods (SmallVectorImpl< const ObjCMethodDecl * > &Overridden) const
 Return overridden methods for the given Method.
bool hasSkippedBody () const
 True if the method was a definition but its body was skipped.
void setHasSkippedBody (bool Skipped=true)
const ObjCPropertyDeclfindPropertyDecl (bool CheckOverrides=true) const
 Returns the property associated with this method's selector.
void setDeclImplementation (ImplementationControl ic)
ImplementationControl getImplementationControl () const
bool isThisDeclarationADesignatedInitializer () const
bool isDesignatedInitializerForTheInterface (const ObjCMethodDecl **InitMethod=nullptr) const
bool hasBody () const override
 Determine whether this method has a body.
StmtgetBody () const override
 Retrieve the body of this method, if it has one.
void setLazyBody (uint64_t Offset)
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 *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=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 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 113 of file DeclObjC.h.


Member Typedef Documentation

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

Definition at line 385 of file DeclObjC.h.

Definition at line 345 of file DeclObjC.h.

Definition at line 348 of file DeclObjC.h.

Definition at line 346 of file DeclObjC.h.

typedef llvm::iterator_range<param_iterator> clang::ObjCMethodDecl::param_range

Definition at line 347 of file DeclObjC.h.

Definition at line 387 of file DeclObjC.h.


Member Enumeration Documentation

Enumerator:
None 
Required 
Optional 

Definition at line 115 of file DeclObjC.h.


Member Function Documentation

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

Reimplemented from clang::Decl.

Definition at line 496 of file DeclObjC.h.

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

Definition at line 493 of file DeclObjC.h.

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

Reimplemented from clang::NamedDecl.

Definition at line 491 of file DeclObjC.h.

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

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

Reimplemented from clang::NamedDecl.

Definition at line 492 of file DeclObjC.h.

Referenced by classof().

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

Definition at line 654 of file DeclObjC.cpp.

References AttributeLangSupport::C.

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

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 false if you only want to check the current class.

Definition at line 1097 of file DeclObjC.cpp.

References clang::ObjCPropertyDecl::findPropertyDecl(), getMethodFamily(), clang::Selector::getNumArgs(), getOverriddenMethods(), clang::DeclContext::getParent(), getSelector(), isInstanceMethod(), isPropertyAccessor(), clang::OMF_None, and clang::ObjCContainerDecl::properties().

Referenced by clang::Sema::BuildInstanceMessage(), clang::Sema::CheckObjCBridgeRelatedConversions(), DiagnoseARCUseOfWeakReceiver(), clang::BodyFarm::getBody(), clang::ASTContext::getCommentForDecl(), and clang::Sema::GetIvarBackingPropertyAccessor().

Stmt * ObjCMethodDecl::getBody ( ) const [override, virtual]

Retrieves the "canonical" declaration of the given declaration.

Reimplemented from clang::Decl.

Definition at line 771 of file DeclObjC.cpp.

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

Referenced by clang::BodyFarm::getBody(), and getCanonicalDecl().

Reimplemented from clang::Decl.

Definition at line 265 of file DeclObjC.h.

References getCanonicalDecl().

Definition at line 324 of file DeclObjC.h.

References getClassInterface().

Definition at line 484 of file DeclObjC.h.

References getBody().

Referenced by cleanupDeallocOrFinalize().

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.

Definition at line 288 of file DeclObjC.h.

Referenced by rewriteToObjCProperty().

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

Return overridden methods for the given 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.

Definition at line 1080 of file DeclObjC.cpp.

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

Referenced by findExplicitInstancetypeDeclarer(), findPropertyDecl(), and clang::ASTContext::getOverriddenMethods().

Definition at line 330 of file DeclObjC.h.

Referenced by AdjustRelatedResultType(), clang::CodeGen::CodeGenTypes::arrangeObjCMessageSendSignature(), clang::Sema::BuildClassMessage(), clang::Sema::BuildInstanceMessage(), clang::Sema::CheckARCMethodDecl(), clang::Sema::checkInitMethod(), clang::Sema::CheckMessageArgumentTypes(), checkMethodFamilyMismatch(), CheckMethodOverrideReturn(), clang::Sema::CheckObjCMethodOverride(), CheckRelatedResultTypeCompatibility(), clang::Sema::CodeCompleteObjCMethodDecl(), CompareReturnTypes(), DiagnoseARCUseOfWeakReceiver(), clang::Sema::DiagnosePropertyAccessorMismatch(), clang::CodeGen::CodeGenFunction::EmitObjCBoxedExpr(), clang::CodeGen::CodeGenFunction::EmitObjCCollectionLiteral(), clang::CodeGen::CodeGenFunction::EmitObjCMessageExpr(), clang::CodeGen::CodeGenFunction::EmitObjCMessageExprLValue(), clang::Sema::EmitRelatedResultTypeNote(), clang::Sema::EmitRelatedResultTypeNoteForReturn(), clang::comments::DeclInfo::fill(), findExplicitInstancetypeDeclarer(), clang::CodeGen::CodeGenFunction::generateObjCGetterBody(), clang::ObjCPropertyRefExpr::getGetterResultType(), getMethodFamily(), clang::ASTContext::getObjCEncodingForMethodDecl(), getSendResultType(), handleObjCMethodFamilyAttr(), hasIsEqualMethod(), isAcceptableMethodMismatch(), clang::Sema::MatchTwoMethodDeclarations(), clang::ASTContext::ObjCMethodsAreEqual(), clang::Sema::ProcessPropertyDecl(), ReplaceWithInstancetype(), rewriteToObjCProperty(), clang::CodeGen::CodeGenFunction::StartObjCMethod(), validateBoxingMethod(), clang::ASTDeclWriter::VisitObjCMethodDecl(), and clang::ASTNodeImporter::VisitObjCMethodDecl().

Definition at line 328 of file DeclObjC.h.

References clang::NamedDecl::getDeclName(), and clang::DeclarationName::getObjCSelector().

Referenced by clang::Sema::ActOnAtEnd(), clang::Sema::ActOnMethodDeclaration(), clang::Sema::ActOnStartOfObjCMethodDef(), clang::Sema::ActOnSuperMessage(), addRedeclaredMethods(), AddSuperSendCompletion(), clang::Sema::BuildInstanceMessage(), clang::Sema::CheckMessageArgumentTypes(), clang::Sema::CheckObjCBridgeRelatedConversions(), clang::Sema::CheckObjCMethodOverrides(), clang::Sema::CodeCompleteObjCMethodDecl(), CollectOverriddenMethodsRecurse(), collectOverriddenMethodsSlow(), CompareReturnTypes(), DiagnoseARCUseOfWeakReceiver(), clang::Sema::DiagnoseMissingDesignatedInitOverrides(), clang::Sema::DiagnosePropertyAccessorMismatch(), clang::CodeGen::CodeGenFunction::EmitObjCBoxedExpr(), clang::CodeGen::CodeGenFunction::EmitObjCCollectionLiteral(), clang::Sema::EmitRelatedResultTypeNote(), findExplicitInstancetypeDeclarer(), findPropertyDecl(), getCanonicalDecl(), clang::ObjCPropertyRefExpr::getGetterSelector(), clang::Sema::GetIvarBackingPropertyAccessor(), getMethodFamily(), getNumSelectorLocs(), getOverriddenMethods(), getSelectorLoc(), clang::ObjCPropertyRefExpr::getSetterSelector(), HelperSelectorsForTypoCorrection(), HelperToDiagnoseMismatchedMethodsInGlobalPool(), isAcceptableMethodMismatch(), isAcceptableObjCMethod(), isDesignatedInitializerForTheInterface(), clang::Sema::IvarBacksCurrentMethodAccessor(), clang::MangleContext::mangleObjCMethodName(), moveMethodToBackOfGlobalList(), clang::Sema::ProcessPropertyDecl(), rewriteToObjCProperty(), sel_param_end(), setMethodParams(), clang::CodeGen::CodeGenFunction::StartObjCMethod(), and clang::Sema::WarnExactTypedMethods().

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

Definition at line 702 of file DeclObjC.cpp.

References getNumSelectorLocs(), and getSelectorLoc().

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

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

Definition at line 336 of file DeclObjC.h.

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

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

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

Source range that this declaration covers.

Reimplemented from clang::Decl.

Definition at line 293 of file DeclObjC.h.

References clang::Decl::getLocation(), and getLocEnd().

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

bool clang::ObjCMethodDecl::hasBody ( ) const [inline, override, virtual]

Determine whether this method has a body.

Reimplemented from clang::Decl.

Definition at line 477 of file DeclObjC.h.

References clang::LazyOffsetPtr< T, OffsT, Get >::isValid().

Referenced by isThisDeclarationADefinition().

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

Definition at line 445 of file DeclObjC.h.

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

Parameters:
InitMethodif non-null and the function returns true, it receives the method declaration that was marked with the designated initializer attribute.

Definition at line 664 of file DeclObjC.cpp.

References getClassInterface(), clang::Decl::getDeclContext(), getMethodFamily(), getSelector(), and clang::OMF_init.

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

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.

Definition at line 430 of file DeclObjC.h.

Referenced by clang::Sema::ActOnMethodDeclaration(), clang::ObjCMethodCall::canBeOverridenInSubclass(), clang::Sema::CheckObjCMethodOverrides(), collectOverriddenMethodsSlow(), getOverriddenMethods(), and setOverriding().

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

Definition at line 282 of file DeclObjC.h.

Referenced by getCanonicalDecl(), and getOverriddenMethods().

Returns whether this specific method is a definition.

Definition at line 488 of file DeclObjC.h.

References hasBody().

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

Definition at line 659 of file DeclObjC.cpp.

References getMethodFamily(), and clang::OMF_init.

Definition at line 361 of file DeclObjC.h.

Definition at line 362 of file DeclObjC.h.

Definition at line 389 of file DeclObjC.h.

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

Referenced by getMethodFamily().

Definition at line 392 of file DeclObjC.h.

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

ArrayRef<ParmVarDecl*> clang::ObjCMethodDecl::parameters ( ) const [inline]

Definition at line 351 of file DeclObjC.h.

References param_begin(), and param_end().

void ObjCMethodDecl::setAsRedeclaration ( const ObjCMethodDecl PrevMethod)
void clang::ObjCMethodDecl::setBody ( Stmt B) [inline]

Definition at line 485 of file DeclObjC.h.

Definition at line 405 of file DeclObjC.h.

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

Definition at line 456 of file DeclObjC.h.

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

void clang::ObjCMethodDecl::setDefined ( bool  isDefined) [inline]
void clang::ObjCMethodDecl::setHasSkippedBody ( bool  Skipped = true) [inline]

Definition at line 446 of file DeclObjC.h.

Definition at line 411 of file DeclObjC.h.

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

void clang::ObjCMethodDecl::setLazyBody ( uint64_t  Offset) [inline]

Definition at line 482 of file DeclObjC.h.

void ObjCMethodDecl::setMethodParams ( ASTContext C,
ArrayRef< ParmVarDecl * >  Params,
ArrayRef< SourceLocation SelLocs = llvm::None 
)
void clang::ObjCMethodDecl::setOverriding ( bool  isOverriding) [inline]

Definition at line 431 of file DeclObjC.h.

References isOverriding().

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

void clang::ObjCMethodDecl::setPropertyAccessor ( bool  isAccessor) [inline]

Note whether this method has a related result type.

Definition at line 279 of file DeclObjC.h.

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

Definition at line 331 of file DeclObjC.h.

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

Definition at line 341 of file DeclObjC.h.

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

Definition at line 403 of file DeclObjC.h.

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

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

Definition at line 413 of file DeclObjC.h.

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


Friends And Related Function Documentation

friend class ASTDeclReader [friend]

Reimplemented from clang::DeclContext.

Definition at line 500 of file DeclObjC.h.

friend class ASTDeclWriter [friend]

Reimplemented from clang::Decl.

Definition at line 501 of file DeclObjC.h.


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