/// to for code generation purposes. Note that the enumerator constants may
/// have a different type than this does.
QualType IntegerType;
-
+
+ /// \brief If the enumeration was instantiated from an enumeration
+ /// within a class or function template, this pointer refers to the
+ /// enumeration declared within the template.
+ EnumDecl *InstantiatedFrom;
+
EnumDecl(DeclContext *DC, SourceLocation L,
IdentifierInfo *Id)
- : TagDecl(Enum, TK_enum, DC, L, Id) {
+ : TagDecl(Enum, TK_enum, DC, L, Id), InstantiatedFrom(0) {
IntegerType = QualType();
}
public:
/// \brief Set the underlying integer type.
void setIntegerType(QualType T) { IntegerType = T; }
+ /// \brief 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.
+ EnumDecl *getInstantiatedFromMemberEnum() const {
+ return InstantiatedFrom;
+ }
+
+ void setInstantiationOfMemberEnum(EnumDecl *IF) { InstantiatedFrom = IF; }
+
static bool classof(const Decl *D) { return D->getKind() == Enum; }
static bool classof(const EnumDecl *D) { return true; }
};
EnumDecl *Enum = EnumDecl::Create(SemaRef.Context, Owner,
D->getLocation(), D->getIdentifier(),
/*PrevDecl=*/0);
+ Enum->setInstantiationOfMemberEnum(D);
Enum->setAccess(D->getAccess());
Owner->addDecl(SemaRef.Context, Enum);
Enum->startDefinition();
return Ctx.getCanonicalDecl(Function->getInstantiatedFromMemberFunction())
== Ctx.getCanonicalDecl(D);
- // FIXME: Need something similar to the above for EnumDecls.
+ if (EnumDecl *Enum = dyn_cast<EnumDecl>(Other))
+ return Ctx.getCanonicalDecl(Enum->getInstantiatedFromMemberEnum())
+ == Ctx.getCanonicalDecl(D);
// FIXME: How can we find instantiations of anonymous unions?