clang  6.0.0svn
Public Member Functions | Static Public Member Functions | Friends | List of all members
clang::Selector Class Reference

Smart pointer class that efficiently represents Objective-C method names. More...

#include "clang/Basic/IdentifierTable.h"

Public Member Functions

 Selector ()=default
 The default ctor should only be used when creating data structures that will contain selectors. More...
 
 Selector (uintptr_t V)
 
bool operator== (Selector RHS) const
 operator==/!= - Indicate whether the specified selectors are identical. More...
 
bool operator!= (Selector RHS) const
 
void * getAsOpaquePtr () const
 
bool isNull () const
 Determine whether this is the empty selector. More...
 
bool isKeywordSelector () const
 
bool isUnarySelector () const
 
unsigned getNumArgs () const
 
IdentifierInfogetIdentifierInfoForSlot (unsigned argIndex) const
 Retrieve the identifier at a given position in the selector. More...
 
StringRef getNameForSlot (unsigned argIndex) const
 Retrieve the name at a given position in the selector. More...
 
std::string getAsString () const
 Derive the full selector name (e.g. More...
 
void print (llvm::raw_ostream &OS) const
 Prints the full selector name (e.g. "foo:bar:"). More...
 
ObjCMethodFamily getMethodFamily () const
 Derive the conventional family of this method. More...
 
ObjCStringFormatFamily getStringFormatFamily () const
 

Static Public Member Functions

static Selector getEmptyMarker ()
 
static Selector getTombstoneMarker ()
 
static ObjCInstanceTypeFamily getInstTypeMethodFamily (Selector sel)
 

Friends

class Diagnostic
 
class SelectorTable
 
class DeclarationName
 

Detailed Description

Smart pointer class that efficiently represents Objective-C method names.

This class will either point to an IdentifierInfo or a MultiKeywordSelector (which is private). This enables us to optimize selectors that take no arguments and selectors that take 1 argument, which accounts for 78% of all selectors in Cocoa.h.

Definition at line 643 of file IdentifierTable.h.

Constructor & Destructor Documentation

◆ Selector() [1/2]

clang::Selector::Selector ( )
default

The default ctor should only be used when creating data structures that will contain selectors.

◆ Selector() [2/2]

clang::Selector::Selector ( uintptr_t  V)
inline

Definition at line 695 of file IdentifierTable.h.

Member Function Documentation

◆ getAsOpaquePtr()

void* clang::Selector::getAsOpaquePtr ( ) const
inline

◆ getAsString()

std::string Selector::getAsString ( ) const

◆ getEmptyMarker()

static Selector clang::Selector::getEmptyMarker ( )
inlinestatic

◆ getIdentifierInfoForSlot()

IdentifierInfo * Selector::getIdentifierInfoForSlot ( unsigned  argIndex) const

Retrieve the identifier at a given position in the selector.

Note that the identifier pointer returned may be NULL. Clients that only care about the text of the identifier string, and not the specific, uniqued identifier pointer, should use getNameForSlot(), which returns an empty string when the identifier pointer would be NULL.

Parameters
argIndexThe index for which we want to retrieve the identifier. This index shall be less than getNumArgs() unless this is a keyword selector, in which case 0 is the only permissible value.
Returns
the uniqued identifier for this slot, or NULL if this slot has no corresponding identifier.

Definition at line 444 of file IdentifierTable.cpp.

References clang::MultiKeywordSelector::getIdentifierInfoForSlot().

Referenced by clang::ObjCMethodCall::argumentsMayEscape(), getInstTypeMethodFamily(), getStandardSelLoc(), clang::ASTImporter::Import(), LookupMethodInReceiverType(), clang::CodeGen::CodeGenFunction::StartObjCMethod(), and startsWithWord().

◆ getInstTypeMethodFamily()

ObjCInstanceTypeFamily Selector::getInstTypeMethodFamily ( Selector  sel)
static

◆ getMethodFamily()

ObjCMethodFamily clang::Selector::getMethodFamily ( ) const
inline

Derive the conventional family of this method.

Definition at line 756 of file IdentifierTable.h.

Referenced by checkFoundationAPI(), isGeneralizedObjectRef(), and clang::Sema::ParseObjCSelectorExpression().

◆ getNameForSlot()

StringRef Selector::getNameForSlot ( unsigned  argIndex) const

Retrieve the name at a given position in the selector.

Parameters
argIndexThe index for which we want to retrieve the name. This index shall be less than getNumArgs() unless this is a keyword selector, in which case 0 is the only permissible value.
Returns
the name for this slot, which may be the empty string if no name was supplied.

Definition at line 455 of file IdentifierTable.cpp.

References clang::IdentifierInfo::getName().

Referenced by checkObjCPointerIntrospection(), findCapturingExpr(), hasDefaultGetterName(), hasDefaultSetterName(), isAcceptableMethodMismatch(), isCallToSelfClass(), isGeneralizedObjectRef(), isKnownDeallocObjCMethodName(), isSetterLikeSelector(), isUnitTest(), and rewriteToObjCProperty().

◆ getNumArgs()

unsigned Selector::getNumArgs ( ) const

◆ getStringFormatFamily()

ObjCStringFormatFamily clang::Selector::getStringFormatFamily ( ) const
inline

Definition at line 760 of file IdentifierTable.h.

Referenced by DiagnoseCStringFormatDirectiveInObjCAPI().

◆ getTombstoneMarker()

static Selector clang::Selector::getTombstoneMarker ( )
inlinestatic

◆ isKeywordSelector()

bool clang::Selector::isKeywordSelector ( ) const
inline

Definition at line 713 of file IdentifierTable.h.

Referenced by isGeneralizedObjectRef().

◆ isNull()

bool clang::Selector::isNull ( ) const
inline

◆ isUnarySelector()

bool clang::Selector::isUnarySelector ( ) const
inline

◆ operator!=()

bool clang::Selector::operator!= ( Selector  RHS) const
inline

Definition at line 701 of file IdentifierTable.h.

◆ operator==()

bool clang::Selector::operator== ( Selector  RHS) const
inline

operator==/!= - Indicate whether the specified selectors are identical.

Definition at line 698 of file IdentifierTable.h.

◆ print()

void Selector::print ( llvm::raw_ostream &  OS) const

Prints the full selector name (e.g. "foo:bar:").

Definition at line 495 of file IdentifierTable.cpp.

References clang::getAsString().

Referenced by CompareReturnTypes(), isImplicitSelf(), clang::MangleContext::mangleObjCMethodNameWithoutSize(), and clang::DeclarationName::print().

Friends And Related Function Documentation

◆ DeclarationName

friend class DeclarationName
friend

Definition at line 690 of file IdentifierTable.h.

◆ Diagnostic

friend class Diagnostic
friend

Definition at line 644 of file IdentifierTable.h.

◆ SelectorTable

friend class SelectorTable
friend

Definition at line 689 of file IdentifierTable.h.


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