clang API Documentation
#include <Decl.h>
Public Types | |
typedef specific_decl_iterator < EnumConstantDecl > | enumerator_iterator |
typedef llvm::iterator_range < specific_decl_iterator < EnumConstantDecl > > enumerator_range;enumerator_range enumerators() const {return enumerator_range(enumerator_begin(), enumerator_end());}enumerator_iterator enumerator_begin() const {const EnumDecl *E=getDefinition();if(!E) E=this;return enumerator_iterator(E-> decls_begin());}enumerator_iterator enumerator_end() const {const EnumDecl *E=getDefinition();if(!E) E=this;return enumerator_iterator(E-> | decls_end ()) |
Public Member Functions | |
EnumDecl * | getCanonicalDecl () override |
Retrieves the "canonical" declaration of the given declaration. | |
const EnumDecl * | getCanonicalDecl () const |
EnumDecl * | getPreviousDecl () |
Return the previous declaration of this declaration or NULL if this is the first declaration. | |
const EnumDecl * | getPreviousDecl () const |
EnumDecl * | getMostRecentDecl () |
Returns the most recent (re)declaration of this declaration. | |
const EnumDecl * | getMostRecentDecl () const |
Returns the most recent (re)declaration of this declaration. | |
EnumDecl * | getDefinition () const |
void | completeDefinition (QualType NewType, QualType PromotionType, unsigned NumPositiveBits, unsigned NumNegativeBits) |
QualType | getPromotionType () const |
void | setPromotionType (QualType T) |
Set the promotion type. | |
QualType | getIntegerType () const |
void | setIntegerType (QualType T) |
Set the underlying integer type. | |
void | setIntegerTypeSourceInfo (TypeSourceInfo *TInfo) |
Set the underlying integer type source info. | |
TypeSourceInfo * | getIntegerTypeSourceInfo () const |
Return the type source info for the underlying integer type, if no type source info exists, return 0. | |
SourceRange | getIntegerTypeRange () const LLVM_READONLY |
Retrieve the source range that covers the underlying type if specified. | |
unsigned | getNumPositiveBits () const |
Returns the width in bits required to store all the non-negative enumerators of this enum. | |
void | setNumPositiveBits (unsigned Num) |
unsigned | getNumNegativeBits () const |
Returns the width in bits required to store all the negative enumerators of this enum. These widths include the rightmost leading 1; that is: | |
void | setNumNegativeBits (unsigned Num) |
bool | isScoped () const |
Returns true if this is a C++11 scoped enumeration. | |
bool | isScopedUsingClassTag () const |
Returns true if this is a C++11 scoped enumeration. | |
bool | isFixed () const |
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying type. | |
bool | isComplete () const |
Returns true if this can be considered a complete type. | |
EnumDecl * | getInstantiatedFromMemberEnum () const |
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. | |
TemplateSpecializationKind | getTemplateSpecializationKind () const |
If this enumeration is a member of a specialization of a templated class, determine what kind of template specialization or instantiation this is. | |
void | setTemplateSpecializationKind (TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation()) |
For an enumeration member that was instantiated from a member enumeration of a templated class, set the template specialiation kind. | |
MemberSpecializationInfo * | getMemberSpecializationInfo () const |
If this enumeration is an instantiation of a member enumeration of a class template specialization, retrieves the member specialization information. | |
void | setInstantiationOfMemberEnum (EnumDecl *ED, TemplateSpecializationKind TSK) |
Specify that this enumeration is an instantiation of the member enumeration ED. | |
Static Public Member Functions | |
static EnumDecl * | Create (ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed) |
static EnumDecl * | CreateDeserialized (ASTContext &C, unsigned ID) |
static bool | classof (const Decl *D) |
static bool | classofKind (Kind K) |
Friends | |
class | ASTDeclReader |
EnumDecl - 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.
typedef llvm::iterator_range<specific_decl_iterator<EnumConstantDecl>> enumerator_range; enumerator_range enumerators() const { return enumerator_range(enumerator_begin(), enumerator_end()); } enumerator_iterator enumerator_begin() const { const EnumDecl *E = getDefinition(); if (!E) E = this; return enumerator_iterator(E->decls_begin()); } enumerator_iterator enumerator_end() const { const EnumDecl *E = getDefinition(); if (!E) E = this; return enumerator_iterator(E-> clang::EnumDecl::decls_end()) |
static bool clang::EnumDecl::classof | ( | const Decl * | D | ) | [inline, static] |
Reimplemented from clang::TagDecl.
Definition at line 3111 of file Decl.h.
References clang::Decl::getKind().
static bool clang::EnumDecl::classofKind | ( | Kind | K | ) | [inline, static] |
Reimplemented from clang::TagDecl.
void EnumDecl::completeDefinition | ( | QualType | NewType, |
QualType | PromotionType, | ||
unsigned | NumPositiveBits, | ||
unsigned | NumNegativeBits | ||
) |
completeDefinition - When created, the EnumDecl corresponds to a forward-declared enum. This method is used to mark the declaration as being defined; it's enumerators have already been added (via DeclContext::addDecl). NewType is the new underlying type of the enumeration type.
Definition at line 3472 of file Decl.cpp.
References clang::TagDecl::completeDefinition(), clang::QualType::getTypePtr(), clang::TagDecl::isCompleteDefinition(), setNumNegativeBits(), and setNumPositiveBits().
Referenced by clang::Sema::ActOnEnumBody(), and clang::ASTNodeImporter::ImportDefinition().
EnumDecl * EnumDecl::Create | ( | ASTContext & | C, |
DeclContext * | DC, | ||
SourceLocation | StartLoc, | ||
SourceLocation | IdLoc, | ||
IdentifierInfo * | Id, | ||
EnumDecl * | PrevDecl, | ||
bool | IsScoped, | ||
bool | IsScopedUsingClassTag, | ||
bool | IsFixed | ||
) | [static] |
Definition at line 3445 of file Decl.cpp.
References AttributeLangSupport::C, clang::ASTContext::getLangOpts(), clang::ASTContext::getTypeDeclType(), and clang::TagDecl::MayHaveOutOfDateDef.
Referenced by clang::Sema::ActOnTag(), and clang::ASTNodeImporter::VisitEnumDecl().
EnumDecl * EnumDecl::CreateDeserialized | ( | ASTContext & | C, |
unsigned | ID | ||
) | [static] |
Definition at line 3458 of file Decl.cpp.
References AttributeLangSupport::C, clang::ASTContext::getLangOpts(), and clang::TagDecl::MayHaveOutOfDateDef.
EnumDecl* clang::EnumDecl::getCanonicalDecl | ( | ) | [inline, override, virtual] |
Retrieves the "canonical" declaration of the given declaration.
Reimplemented from clang::TagDecl.
Definition at line 2934 of file Decl.h.
References clang::TagDecl::getCanonicalDecl().
Referenced by isInstantiationOf(), and clang::ASTDeclReader::VisitEnumDecl().
const EnumDecl* clang::EnumDecl::getCanonicalDecl | ( | ) | const [inline] |
Reimplemented from clang::TagDecl.
EnumDecl* clang::EnumDecl::getDefinition | ( | ) | const [inline] |
getDefinition - Returns the TagDecl that actually defines this struct/union/class/enum. When determining whether or not a struct/union/class/enum has a definition, one should use this method as opposed to 'isDefinition'. 'isDefinition' indicates whether or not a specific TagDecl is defining declaration, not whether or not the struct/union/class/enum type is defined. This method returns NULL if there is no TagDecl that defines the struct/union/class/enum.
Reimplemented from clang::TagDecl.
Definition at line 2956 of file Decl.h.
References getDefinition().
Referenced by appendEnumType(), clang::Sema::CodeCompleteCase(), clang::ASTNodeImporter::ImportDefinition(), clang::Sema::InstantiateClassMembers(), clang::Sema::InstantiateEnum(), and clang::Sema::InstantiateVariableDefinition().
EnumDecl * EnumDecl::getInstantiatedFromMemberEnum | ( | ) | const |
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.
Definition at line 3503 of file Decl.cpp.
References clang::MemberSpecializationInfo::getInstantiatedFrom().
Referenced by clang::Sema::CheckMemberSpecialization(), clang::Sema::InstantiateClassMembers(), clang::Sema::InstantiateEnum(), isInstantiationOf(), and clang::Sema::RequireCompleteDeclContext().
QualType clang::EnumDecl::getIntegerType | ( | ) | const [inline] |
getIntegerType - Return the integer type this enum decl corresponds to. This returns a null QualType for an enum forward definition with no fixed underlying type.
Definition at line 3011 of file Decl.h.
Referenced by clang::Sema::ActOnEnumBody(), clang::Sema::ActOnTag(), clang::Sema::BuildUnaryTransformType(), clang::Sema::CheckEnumConstant(), clang::Sema::CheckEnumRedeclaration(), clang::CodeGen::CodeGenTypes::ConvertType(), getIntegerTypeForEnum(), getRangeForType(), mergeEnumWithInteger(), ObjCEncodingForEnumType(), clang::ASTDeclWriter::VisitEnumDecl(), and clang::ASTNodeImporter::VisitEnumDecl().
SourceRange EnumDecl::getIntegerTypeRange | ( | ) | const |
Retrieve the source range that covers the underlying type if specified.
Definition at line 3466 of file Decl.cpp.
References getIntegerTypeSourceInfo().
Referenced by clang::Sema::CheckEnumRedeclaration().
TypeSourceInfo* clang::EnumDecl::getIntegerTypeSourceInfo | ( | ) | const [inline] |
Return the type source info for the underlying integer type, if no type source info exists, return 0.
Definition at line 3027 of file Decl.h.
Referenced by getIntegerTypeRange(), and clang::ASTDeclWriter::VisitEnumDecl().
MemberSpecializationInfo* clang::EnumDecl::getMemberSpecializationInfo | ( | ) | const [inline] |
If this enumeration is an instantiation of a member enumeration of a class template specialization, retrieves the member specialization information.
Definition at line 3100 of file Decl.h.
Referenced by clang::Sema::CheckMemberSpecialization(), getTemplateSpecializationKind(), clang::Sema::InstantiateEnum(), clang::Sema::RequireCompleteDeclContext(), setTemplateSpecializationKind(), clang::ASTDeclWriter::VisitEnumDecl(), and clang::ASTDeclReader::VisitEnumDecl().
EnumDecl* clang::EnumDecl::getMostRecentDecl | ( | ) | [inline] |
Returns the most recent (re)declaration of this declaration.
Reimplemented from clang::Redeclarable< TagDecl >.
Definition at line 2949 of file Decl.h.
Referenced by clang::ASTDeclWriter::VisitEnumDecl().
const EnumDecl* clang::EnumDecl::getMostRecentDecl | ( | ) | const [inline] |
Returns the most recent (re)declaration of this declaration.
Reimplemented from clang::Redeclarable< TagDecl >.
unsigned clang::EnumDecl::getNumNegativeBits | ( | ) | const [inline] |
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
Definition at line 3054 of file Decl.h.
Referenced by CheckForDuplicateEnumValues(), getRangeForType(), clang::ASTNodeImporter::ImportDefinition(), and clang::ASTDeclWriter::VisitEnumDecl().
unsigned clang::EnumDecl::getNumPositiveBits | ( | ) | const [inline] |
Returns the width in bits required to store all the non-negative enumerators of this enum.
Definition at line 3037 of file Decl.h.
Referenced by CheckForDuplicateEnumValues(), getRangeForType(), clang::ASTNodeImporter::ImportDefinition(), and clang::ASTDeclWriter::VisitEnumDecl().
EnumDecl* clang::EnumDecl::getPreviousDecl | ( | ) | [inline] |
Return the previous declaration of this declaration or NULL if this is the first declaration.
Reimplemented from clang::Redeclarable< TagDecl >.
Definition at line 2941 of file Decl.h.
Referenced by clang::ASTContext::getEnumType().
const EnumDecl* clang::EnumDecl::getPreviousDecl | ( | ) | const [inline] |
Reimplemented from clang::Redeclarable< TagDecl >.
QualType clang::EnumDecl::getPromotionType | ( | ) | const [inline] |
getPromotionType - Return the integer type that enumerators should promote to.
Definition at line 3003 of file Decl.h.
Referenced by clang::ASTNodeImporter::ImportDefinition(), and clang::ASTDeclWriter::VisitEnumDecl().
If this enumeration is a member of a specialization of a templated class, determine what kind of template specialization or instantiation this is.
Definition at line 3485 of file Decl.cpp.
References getMemberSpecializationInfo(), and clang::TSK_Undeclared.
Referenced by clang::Sema::CheckMemberSpecialization().
bool clang::EnumDecl::isComplete | ( | ) | const [inline] |
Returns true if this can be considered a complete type.
Definition at line 3078 of file Decl.h.
Referenced by getIntegerTypeForEnum(), and clang::IsEnumDeclComplete().
bool clang::EnumDecl::isFixed | ( | ) | const [inline] |
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying type.
Definition at line 3073 of file Decl.h.
Referenced by clang::Sema::ActOnEnumBody(), clang::Sema::CheckEnumConstant(), clang::Sema::CheckEnumRedeclaration(), clang::CodeGen::CodeGenTypes::ConvertType(), getRangeForType(), clang::Type::isIncompleteType(), ObjCEncodingForEnumType(), clang::Sema::PerformImplicitConversion(), clang::ASTDeclWriter::VisitEnumDecl(), and clang::ASTNodeImporter::VisitEnumDecl().
bool clang::EnumDecl::isScoped | ( | ) | const [inline] |
Returns true if this is a C++11 scoped enumeration.
Definition at line 3062 of file Decl.h.
Referenced by clang::Sema::ActOnEnumConstant(), clang::Sema::ActOnTag(), clang::Sema::CheckEnumRedeclaration(), getIntegerTypeForEnum(), clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), clang::IsEnumDeclScoped(), clang::ASTDeclWriter::VisitEnumDecl(), and clang::ASTNodeImporter::VisitEnumDecl().
bool clang::EnumDecl::isScopedUsingClassTag | ( | ) | const [inline] |
Returns true if this is a C++11 scoped enumeration.
Definition at line 3067 of file Decl.h.
Referenced by clang::ASTDeclWriter::VisitEnumDecl(), and clang::ASTNodeImporter::VisitEnumDecl().
void clang::EnumDecl::setInstantiationOfMemberEnum | ( | EnumDecl * | ED, |
TemplateSpecializationKind | TSK | ||
) | [inline] |
void clang::EnumDecl::setIntegerType | ( | QualType | T | ) | [inline] |
Set the underlying integer type.
Definition at line 3020 of file Decl.h.
References clang::QualType::getTypePtrOrNull().
Referenced by clang::Sema::ActOnTag(), clang::ASTNodeImporter::VisitEnumDecl(), and clang::ASTDeclReader::VisitEnumDecl().
void clang::EnumDecl::setIntegerTypeSourceInfo | ( | TypeSourceInfo * | TInfo | ) | [inline] |
Set the underlying integer type source info.
Definition at line 3023 of file Decl.h.
Referenced by clang::Sema::ActOnTag(), and clang::ASTDeclReader::VisitEnumDecl().
void clang::EnumDecl::setNumNegativeBits | ( | unsigned | Num | ) | [inline] |
Definition at line 3057 of file Decl.h.
Referenced by completeDefinition(), and clang::ASTDeclReader::VisitEnumDecl().
void clang::EnumDecl::setNumPositiveBits | ( | unsigned | Num | ) | [inline] |
Definition at line 3040 of file Decl.h.
Referenced by completeDefinition(), and clang::ASTDeclReader::VisitEnumDecl().
void clang::EnumDecl::setPromotionType | ( | QualType | T | ) | [inline] |
Set the promotion type.
Definition at line 3006 of file Decl.h.
Referenced by clang::Sema::ActOnTag(), and clang::ASTDeclReader::VisitEnumDecl().
void EnumDecl::setTemplateSpecializationKind | ( | TemplateSpecializationKind | TSK, |
SourceLocation | PointOfInstantiation = SourceLocation() |
||
) |
For an enumeration member that was instantiated from a member enumeration of a templated class, set the template specialiation kind.
Definition at line 3492 of file Decl.cpp.
References getMemberSpecializationInfo(), clang::MemberSpecializationInfo::getPointOfInstantiation(), clang::SourceLocation::isInvalid(), clang::SourceLocation::isValid(), clang::MemberSpecializationInfo::setPointOfInstantiation(), clang::MemberSpecializationInfo::setTemplateSpecializationKind(), and clang::TSK_ExplicitSpecialization.
Referenced by clang::Sema::CheckMemberSpecialization(), clang::Sema::InstantiateEnum(), and clang::Sema::InstantiateVariableDefinition().
friend class ASTDeclReader [friend] |
Reimplemented from clang::TagDecl.