clang 20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
clang::DeclarationName Class Reference

The name of a declaration. More...

#include "clang/AST/DeclarationName.h"

Public Types

enum  NameKind {
  Identifier = StoredIdentifier , ObjCZeroArgSelector = StoredObjCZeroArgSelector , ObjCOneArgSelector = StoredObjCOneArgSelector , CXXConstructorName = StoredCXXConstructorName ,
  CXXDestructorName = StoredCXXDestructorName , CXXConversionFunctionName = StoredCXXConversionFunctionName , CXXOperatorName = StoredCXXOperatorName , CXXDeductionGuideName ,
  CXXLiteralOperatorName , CXXUsingDirective , ObjCMultiArgSelector
}
 The kind of the name stored in this DeclarationName. More...
 

Public Member Functions

 DeclarationName ()
 Construct an empty declaration name.
 
 DeclarationName (const IdentifierInfo *II)
 Construct a declaration name from an IdentifierInfo *.
 
 DeclarationName (Selector Sel)
 Construct a declaration name from an Objective-C selector.
 
 operator bool () const
 Evaluates true when this declaration name is non-empty.
 
bool isEmpty () const
 Evaluates true when this declaration name is empty.
 
bool isIdentifier () const
 Predicate functions for querying what type of name this is.
 
bool isObjCZeroArgSelector () const
 
bool isObjCOneArgSelector () const
 
NameKind getNameKind () const
 Determine what kind of name this is.
 
bool isDependentName () const
 Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself dependent.
 
std::string getAsString () const
 Retrieve the human-readable string for this name.
 
IdentifierInfogetAsIdentifierInfo () const
 Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't a simple identifier.
 
uintptr_t getAsOpaqueInteger () const
 Get the representation of this declaration name as an opaque integer.
 
void * getAsOpaquePtr () const
 Get the representation of this declaration name as an opaque pointer.
 
QualType getCXXNameType () const
 If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
 
TemplateDeclgetCXXDeductionGuideTemplate () const
 If this name is the name of a C++ deduction guide, return the template associated with that name.
 
OverloadedOperatorKind getCXXOverloadedOperator () const
 If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of overloaded operator.
 
const IdentifierInfogetCXXLiteralIdentifier () const
 If this name is the name of a literal operator, retrieve the identifier associated with it.
 
Selector getObjCSelector () const
 Get the Objective-C selector stored in this declaration name.
 
void * getFETokenInfo () const
 Get and set FETokenInfo.
 
void setFETokenInfo (void *T)
 
void print (raw_ostream &OS, const PrintingPolicy &Policy) const
 
void dump () const
 

Static Public Member Functions

static DeclarationName getUsingDirectiveName ()
 Returns the name for all C++ using-directives.
 
static DeclarationName getFromOpaquePtr (void *P)
 Get a declaration name from an opaque pointer returned by getAsOpaquePtr.
 
static DeclarationName getFromOpaqueInteger (uintptr_t P)
 Get a declaration name from an opaque integer returned by getAsOpaqueInteger.
 
static DeclarationName getEmptyMarker ()
 
static DeclarationName getTombstoneMarker ()
 
static int compare (DeclarationName LHS, DeclarationName RHS)
 

Friends

class DeclarationNameTable
 
class NamedDecl
 
bool operator== (DeclarationName LHS, DeclarationName RHS)
 Determine whether the specified names are identical.
 
bool operator!= (DeclarationName LHS, DeclarationName RHS)
 Determine whether the specified names are different.
 

Detailed Description

The name of a declaration.

In the common case, this just stores an IdentifierInfo pointer to a normal name. However, it also provides encodings for Objective-C selectors (optimizing zero- and one-argument selectors, which make up 78% percent of all selectors in Cocoa.h), special C++ names for constructors, destructors, and conversion functions, and C++ overloaded operators.

Definition at line 144 of file DeclarationName.h.

Member Enumeration Documentation

◆ NameKind

The kind of the name stored in this DeclarationName.

The first 7 enumeration values are stored inline and correspond to frequently used kinds. The rest is stored in DeclarationNameExtra and correspond to infrequently used kinds.

Enumerator
Identifier 
ObjCZeroArgSelector 
ObjCOneArgSelector 
CXXConstructorName 
CXXDestructorName 
CXXConversionFunctionName 
CXXOperatorName 
CXXDeductionGuideName 
CXXLiteralOperatorName 
CXXUsingDirective 
ObjCMultiArgSelector 

Definition at line 208 of file DeclarationName.h.

Constructor & Destructor Documentation

◆ DeclarationName() [1/3]

clang::DeclarationName::DeclarationName ( )
inline

Construct an empty declaration name.

Definition at line 357 of file DeclarationName.h.

◆ DeclarationName() [2/3]

clang::DeclarationName::DeclarationName ( const IdentifierInfo II)
inline

Construct a declaration name from an IdentifierInfo *.

Definition at line 360 of file DeclarationName.h.

◆ DeclarationName() [3/3]

clang::DeclarationName::DeclarationName ( Selector  Sel)
inline

Construct a declaration name from an Objective-C selector.

Definition at line 365 of file DeclarationName.h.

Member Function Documentation

◆ compare()

int DeclarationName::compare ( DeclarationName  LHS,
DeclarationName  RHS 
)
static

◆ dump()

LLVM_DUMP_METHOD void DeclarationName::dump ( ) const

Definition at line 278 of file DeclarationName.cpp.

◆ getAsIdentifierInfo()

IdentifierInfo * clang::DeclarationName::getAsIdentifierInfo ( ) const
inline

◆ getAsOpaqueInteger()

uintptr_t clang::DeclarationName::getAsOpaqueInteger ( ) const
inline

Get the representation of this declaration name as an opaque integer.

Definition at line 427 of file DeclarationName.h.

Referenced by clang::operator<<().

◆ getAsOpaquePtr()

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

Get the representation of this declaration name as an opaque pointer.

Definition at line 430 of file DeclarationName.h.

◆ getAsString()

std::string DeclarationName::getAsString ( ) const

◆ getCXXDeductionGuideTemplate()

TemplateDecl * clang::DeclarationName::getCXXDeductionGuideTemplate ( ) const
inline

◆ getCXXLiteralIdentifier()

const IdentifierInfo * clang::DeclarationName::getCXXLiteralIdentifier ( ) const
inline

If this name is the name of a literal operator, retrieve the identifier associated with it.

Definition at line 482 of file DeclarationName.h.

Referenced by clang::Sema::CheckLiteralOperatorDeclaration(), compare(), clang::FunctionDecl::getLiteralIdentifier(), clang::ASTImporter::Import(), IsStructurallyEquivalent(), and print().

◆ getCXXNameType()

QualType clang::DeclarationName::getCXXNameType ( ) const
inline

If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.

Definition at line 449 of file DeclarationName.h.

Referenced by compare(), clang::DeclarationNameInfo::containsUnexpandedParameterPack(), clang::Sema::DiagnoseUnexpandedParameterPack(), clang::ASTImporter::Import(), isDependentName(), clang::DeclarationNameInfo::isInstantiationDependent(), IsStructurallyEquivalent(), LookupDirect(), and print().

◆ getCXXOverloadedOperator()

OverloadedOperatorKind clang::DeclarationName::getCXXOverloadedOperator ( ) const
inline

◆ getEmptyMarker()

static DeclarationName clang::DeclarationName::getEmptyMarker ( )
inlinestatic

◆ getFETokenInfo()

void * clang::DeclarationName::getFETokenInfo ( ) const
inline

Get and set FETokenInfo.

The language front-end is allowed to associate arbitrary metadata with some kinds of declaration names, including normal identifiers and C++ constructors, destructors, and conversion functions.

Definition at line 502 of file DeclarationName.h.

◆ getFromOpaqueInteger()

static DeclarationName clang::DeclarationName::getFromOpaqueInteger ( uintptr_t  P)
inlinestatic

Get a declaration name from an opaque integer returned by getAsOpaqueInteger.

Definition at line 441 of file DeclarationName.h.

References P.

Referenced by clang::FormatASTNodeDiagnosticArgument().

◆ getFromOpaquePtr()

static DeclarationName clang::DeclarationName::getFromOpaquePtr ( void *  P)
inlinestatic

Get a declaration name from an opaque pointer returned by getAsOpaquePtr.

Definition at line 433 of file DeclarationName.h.

References P.

Referenced by llvm::PointerLikeTypeTraits< clang::DeclarationName >::getFromVoidPointer().

◆ getNameKind()

NameKind clang::DeclarationName::getNameKind ( ) const
inline

◆ getObjCSelector()

Selector clang::DeclarationName::getObjCSelector ( ) const
inline

◆ getTombstoneMarker()

static DeclarationName clang::DeclarationName::getTombstoneMarker ( )
inlinestatic

◆ getUsingDirectiveName()

static DeclarationName clang::DeclarationName::getUsingDirectiveName ( )
inlinestatic

Returns the name for all C++ using-directives.

Definition at line 369 of file DeclarationName.h.

Referenced by clang::ASTImporter::Import(), and clang::DeclContext::all_lookups_iterator::operator++().

◆ isDependentName()

bool DeclarationName::isDependentName ( ) const

Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself dependent.

Note that this does not capture all of the notions of "dependent name", because an identifier can be a dependent name if it is used as the callee in a call expression with dependent arguments.

Definition at line 216 of file DeclarationName.cpp.

References getCXXDeductionGuideTemplate(), getCXXNameType(), clang::Type::isDependentType(), and clang::T.

Referenced by clang::Sema::ActOnDependentMemberExpr(), and clang::Sema::CheckMicrosoftIfExistsSymbol().

◆ isEmpty()

bool clang::DeclarationName::isEmpty ( ) const
inline

◆ isIdentifier()

bool clang::DeclarationName::isIdentifier ( ) const
inline

◆ isObjCOneArgSelector()

bool clang::DeclarationName::isObjCOneArgSelector ( ) const
inline

Definition at line 389 of file DeclarationName.h.

Referenced by hasDefaultSetterName().

◆ isObjCZeroArgSelector()

bool clang::DeclarationName::isObjCZeroArgSelector ( ) const
inline

Definition at line 386 of file DeclarationName.h.

Referenced by hasDefaultGetterName().

◆ operator bool()

clang::DeclarationName::operator bool ( ) const
inlineexplicit

Evaluates true when this declaration name is non-empty.

Definition at line 377 of file DeclarationName.h.

◆ print()

void DeclarationName::print ( raw_ostream &  OS,
const PrintingPolicy Policy 
) const

◆ setFETokenInfo()

void clang::DeclarationName::setFETokenInfo ( void *  T)
inline

Definition at line 509 of file DeclarationName.h.

References clang::T.

Friends And Related Function Documentation

◆ DeclarationNameTable

friend class DeclarationNameTable
friend

Definition at line 145 of file DeclarationName.h.

◆ NamedDecl

friend class NamedDecl
friend

Definition at line 146 of file DeclarationName.h.

◆ operator!=

bool operator!= ( DeclarationName  LHS,
DeclarationName  RHS 
)
friend

Determine whether the specified names are different.

Definition at line 523 of file DeclarationName.h.

◆ operator==

bool operator== ( DeclarationName  LHS,
DeclarationName  RHS 
)
friend

Determine whether the specified names are identical.

Definition at line 518 of file DeclarationName.h.


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