class EnumDecl

Declaration

class EnumDecl : public TagDecl { /* full declaration omitted */ };

Description

Represents an enum. In C++11, enums can be forward-declared with a fixed underlying type, and in C we allow them to be forward-declared with no underlying type as an extension.

Declared at: clang/include/clang/AST/Decl.h:3646

Inherits from: TagDecl

Member Variables

private llvm::PointerUnion<const Type*, TypeSourceInfo*> IntegerType
The underlying type of an enumeration never has any qualifiers, so we can get away with just storing a raw Type*, and thus save an extra pointer when TypeSourceInfo is needed.
private clang::QualType PromotionType
The integer type that values of this type should promote to. In C, enumerators are generally of an integer type directly, but gcc-style large enumerators (and all enumerators in C++) are of the enum type instead.
private clang::MemberSpecializationInfo* SpecializationInfo = nullptr
If this enumeration is an instantiation of a member enumeration of a class template specialization, this is the member specialization information.
private unsigned int ODRHash
Store the ODRHash after first calculation. The corresponding flag HasODRHash is in EnumDeclBits and can be accessed with the provided accessors.

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 TagDecl:

Inherited from DeclContext:

Inherited from TypeDecl:

Inherited from NamedDecl:

Inherited from Decl:

Methods

static clang::EnumDecl* Create(
    clang::ASTContext& C,
    clang::DeclContext* DC,
    clang::SourceLocation StartLoc,
    clang::SourceLocation IdLoc,
    clang::IdentifierInfo* Id,
    clang::EnumDecl* PrevDecl,
    bool IsScoped,
    bool IsScopedUsingClassTag,
    bool IsFixed)

Declared at: clang/include/clang/AST/Decl.h:3753

Parameters

clang::ASTContext& C
clang::DeclContext* DC
clang::SourceLocation StartLoc
clang::SourceLocation IdLoc
clang::IdentifierInfo* Id
clang::EnumDecl* PrevDecl
bool IsScoped
bool IsScopedUsingClassTag
bool IsFixed

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

Declared at: clang/include/clang/AST/Decl.h:3758

Parameters

clang::ASTContext& C
unsigned int ID

EnumDecl(clang::ASTContext& C,
         clang::DeclContext* DC,
         clang::SourceLocation StartLoc,
         clang::SourceLocation IdLoc,
         clang::IdentifierInfo* Id,
         clang::EnumDecl* PrevDecl,
         bool Scoped,
         bool ScopedUsingClassTag,
         bool Fixed)

Declared at: clang/include/clang/AST/Decl.h:3682

Parameters

clang::ASTContext& C
clang::DeclContext* DC
clang::SourceLocation StartLoc
clang::SourceLocation IdLoc
clang::IdentifierInfo* Id
clang::EnumDecl* PrevDecl
bool Scoped
bool ScopedUsingClassTag
bool Fixed

void anchor()

Declared at: clang/include/clang/AST/Decl.h:3686

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

Declared at: clang/include/clang/AST/Decl.h:3911

Parameters

const clang::Decl* D

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

Declared at: clang/include/clang/AST/Decl.h:3912

Parameters

clang::Decl::Kind K

void completeDefinition(
    clang::QualType NewType,
    clang::QualType PromotionType,
    unsigned int NumPositiveBits,
    unsigned int NumNegativeBits)

Description

When created, the EnumDecl corresponds to a forward-declared enum. This method is used to mark the declaration as being defined; its enumerators have already been added (via DeclContext::addDecl). NewType is the new underlying type of the enumeration type.

Declared at: clang/include/clang/AST/Decl.h:3769

Parameters

clang::QualType NewType
clang::QualType PromotionType
unsigned int NumPositiveBits
unsigned int NumNegativeBits

clang::EnumDecl::enumerator_iterator
enumerator_begin() const

Declared at: clang/include/clang/AST/Decl.h:3783

clang::EnumDecl::enumerator_iterator
enumerator_end() const

Declared at: clang/include/clang/AST/Decl.h:3790

clang::EnumDecl::enumerator_range enumerators()
    const

Declared at: clang/include/clang/AST/Decl.h:3779

clang::EnumDecl* getCanonicalDecl()

Description

Retrieves the "canonical" declaration of the given declaration.

Declared at: clang/include/clang/AST/Decl.h:3727

const clang::EnumDecl* getCanonicalDecl() const

Declared at: clang/include/clang/AST/Decl.h:3730

clang::EnumDecl* getDefinition() const

Declared at: clang/include/clang/AST/Decl.h:3749

clang::EnumDecl* getInstantiatedFromMemberEnum()
    const

Description

Returns the enumeration (declared within the template) from which this enumeration type was instantiated, or NULL if this enumeration was not instantiated from any template.

Declared at: clang/include/clang/AST/Decl.h:3885

clang::QualType getIntegerType() const

Description

Return the integer type this enum decl corresponds to. This returns a null QualType for an enum forward definition with no fixed underlying type.

Declared at: clang/include/clang/AST/Decl.h:3806

clang::SourceRange getIntegerTypeRange() const

Description

Retrieve the source range that covers the underlying type if specified.

Declared at: clang/include/clang/AST/Decl.h:3828

clang::TypeSourceInfo* getIntegerTypeSourceInfo()
    const

Description

Return the type source info for the underlying integer type, if no type source info exists, return 0.

Declared at: clang/include/clang/AST/Decl.h:3822

clang::MemberSpecializationInfo*
getMemberSpecializationInfo() const

Description

If this enumeration is an instantiation of a member enumeration of a class template specialization, retrieves the member specialization information.

Declared at: clang/include/clang/AST/Decl.h:3900

const clang::EnumDecl* getMostRecentDecl() const

Declared at: clang/include/clang/AST/Decl.h:3745

clang::EnumDecl* getMostRecentDecl()

Declared at: clang/include/clang/AST/Decl.h:3742

unsigned int getNumNegativeBits() const

Description

Returns the width in bits required to store all the negative enumerators of this enum. These widths include the rightmost leading 1; that is: MOST NEGATIVE ENUMERATOR PATTERN NUM NEGATIVE BITS ------------------------ ------- ----------------- -1 1111111 1 -10 1110110 5 -101 1001011 8

Declared at: clang/include/clang/AST/Decl.h:3843

unsigned int getNumPositiveBits() const

Description

Returns the width in bits required to store all the non-negative enumerators of this enum.

Declared at: clang/include/clang/AST/Decl.h:3832

unsigned int getODRHash()

Declared at: clang/include/clang/AST/Decl.h:3857

const clang::EnumDecl* getPreviousDecl() const

Declared at: clang/include/clang/AST/Decl.h:3738

clang::EnumDecl* getPreviousDecl()

Declared at: clang/include/clang/AST/Decl.h:3734

clang::QualType getPromotionType() const

Description

Return the integer type that enumerators should promote to.

Declared at: clang/include/clang/AST/Decl.h:3798

clang::SourceRange getSourceRange() const

Description

Overrides to provide correct range when there's an enum-base specifier with forward declarations.

Declared at: clang/include/clang/AST/Decl.h:3762

clang::EnumDecl* getTemplateInstantiationPattern()
    const

Description

Retrieve the enum definition from which this enumeration could be instantiated, if it is an instantiation (rather than a non-template).

Declared at: clang/include/clang/AST/Decl.h:3880

clang::TemplateSpecializationKind
getTemplateSpecializationKind() const

Description

If this enumeration is a member of a specialization of a templated class, determine what kind of template specialization or instantiation this is.

Declared at: clang/include/clang/AST/Decl.h:3890

bool hasODRHash() const

Description

True if a valid hash is stored in ODRHash.

Declared at: clang/include/clang/AST/Decl.h:3721

bool isClosed() const

Description

Returns true if this enum is either annotated with enum_extensibility(closed) or isn't annotated with enum_extensibility.

Declared at: clang/include/clang/AST/Decl.h:3868

bool isClosedFlag() const

Description

Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(open).

Declared at: clang/include/clang/AST/Decl.h:3872

bool isClosedNonFlag() const

Description

Returns true if this enum is annotated with neither flag_enum nor enum_extensibility(open).

Declared at: clang/include/clang/AST/Decl.h:3876

bool isComplete() const

Description

Returns true if this can be considered a complete type.

Declared at: clang/include/clang/AST/Decl.h:3860

bool isFixed() const

Description

Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying type.

Declared at: clang/include/clang/AST/Decl.h:3855

bool isScoped() const

Description

Returns true if this is a C++11 scoped enumeration.

Declared at: clang/include/clang/AST/Decl.h:3846

bool isScopedUsingClassTag() const

Description

Returns true if this is a C++11 scoped enumeration.

Declared at: clang/include/clang/AST/Decl.h:3849

void setFixed(bool Fixed = true)

Description

True if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying type.

Declared at: clang/include/clang/AST/Decl.h:3717

Parameters

bool Fixed = true

void setHasODRHash(bool Hash = true)

Declared at: clang/include/clang/AST/Decl.h:3722

Parameters

bool Hash = true

void setInstantiationOfMemberEnum(
    clang::EnumDecl* ED,
    clang::TemplateSpecializationKind TSK)

Description

Specify that this enumeration is an instantiation of the member enumeration ED.

Declared at: clang/include/clang/AST/Decl.h:3906

Parameters

clang::EnumDecl* ED
clang::TemplateSpecializationKind TSK

void setInstantiationOfMemberEnum(
    clang::ASTContext& C,
    clang::EnumDecl* ED,
    clang::TemplateSpecializationKind TSK)

Declared at: clang/include/clang/AST/Decl.h:3688

Parameters

clang::ASTContext& C
clang::EnumDecl* ED
clang::TemplateSpecializationKind TSK

void setIntegerType(clang::QualType T)

Description

Set the underlying integer type.

Declared at: clang/include/clang/AST/Decl.h:3815

Parameters

clang::QualType T

void setIntegerTypeSourceInfo(
    clang::TypeSourceInfo* TInfo)

Description

Set the underlying integer type source info.

Declared at: clang/include/clang/AST/Decl.h:3818

Parameters

clang::TypeSourceInfo* TInfo

void setNumNegativeBits(unsigned int Num)

Description

Returns the width in bits required to store all the negative enumerators of this enum. (see getNumNegativeBits)

Declared at: clang/include/clang/AST/Decl.h:3700

Parameters

unsigned int Num

void setNumPositiveBits(unsigned int Num)

Description

Sets the width in bits required to store all the non-negative enumerators of this enum.

Declared at: clang/include/clang/AST/Decl.h:3693

Parameters

unsigned int Num

void setPromotionType(clang::QualType T)

Description

Set the promotion type.

Declared at: clang/include/clang/AST/Decl.h:3801

Parameters

clang::QualType T

void setScoped(bool Scoped = true)

Description

True if this tag declaration is a scoped enumeration. Only possible in C++11 mode.

Declared at: clang/include/clang/AST/Decl.h:3705

Parameters

bool Scoped = true

void setScopedUsingClassTag(bool ScopedUCT = true)

Description

If this tag declaration is a scoped enum, then this is true if the scoped enum was declared using the class tag, false if it was declared with the struct tag. No meaning is associated if this tag declaration is not a scoped enum.

Declared at: clang/include/clang/AST/Decl.h:3711

Parameters

bool ScopedUCT = true

void setTemplateSpecializationKind(
    clang::TemplateSpecializationKind TSK,
    clang::SourceLocation PointOfInstantiation =
        clang::SourceLocation())

Description

For an enumeration member that was instantiated from a member enumeration of a templated class, set the template specialiation kind.

Declared at: clang/include/clang/AST/Decl.h:3894

Parameters

clang::TemplateSpecializationKind TSK
clang::SourceLocation PointOfInstantiation = clang::SourceLocation()