aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-06-09 23:19:58 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-06-09 23:19:58 +0000
commit39ba4aeca296b1c9f04bde7d9d3cbbf129f1abd3 (patch)
tree0bd41bdbfdd41514deb4fbd92ddf3bade3030d8b
parentd3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8 (diff)
-Changes to TagDecl:
Added TagKind enum. Added getTagKind() method. Added convenience methods: isEnum(), isStruct(), isUnion(), isClass(). -RecordDecl/CXXRecordDecl::Create() accept a TagKind enum instead of a DeclKind one. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52160 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Driver/RewriteObjC.cpp14
-rw-r--r--include/clang/AST/Decl.h34
-rw-r--r--include/clang/AST/DeclCXX.h2
-rw-r--r--lib/AST/ASTContext.cpp14
-rw-r--r--lib/AST/Decl.cpp9
-rw-r--r--lib/AST/DeclCXX.cpp9
-rw-r--r--lib/AST/Type.cpp29
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp6
-rw-r--r--lib/Sema/Sema.cpp6
-rw-r--r--lib/Sema/SemaDecl.cpp28
-rw-r--r--lib/Sema/SemaDeclCXX.cpp2
-rw-r--r--lib/Sema/SemaInit.cpp2
12 files changed, 95 insertions, 60 deletions
diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp
index 694456d670..fe71e54a86 100644
--- a/Driver/RewriteObjC.cpp
+++ b/Driver/RewriteObjC.cpp
@@ -836,7 +836,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
std::string RecName = clsDeclared->getIdentifier()->getName();
RecName += "_IMPL";
IdentifierInfo *II = &Context->Idents.get(RecName.c_str());
- RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+ RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
SourceLocation(), II, 0);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -877,7 +877,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
std::string RecName = clsDeclared->getIdentifier()->getName();
RecName += "_IMPL";
IdentifierInfo *II = &Context->Idents.get(RecName.c_str());
- RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+ RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
SourceLocation(), II, 0);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -1692,7 +1692,7 @@ void RewriteObjC::SynthMsgSendFunctionDecl() {
void RewriteObjC::SynthMsgSendSuperFunctionDecl() {
IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper");
llvm::SmallVector<QualType, 16> ArgTys;
- RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+ RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
SourceLocation(),
&Context->Idents.get("objc_super"), 0);
QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -1735,7 +1735,7 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() {
IdentifierInfo *msgSendIdent =
&Context->Idents.get("objc_msgSendSuper_stret");
llvm::SmallVector<QualType, 16> ArgTys;
- RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+ RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
SourceLocation(),
&Context->Idents.get("objc_super"), 0);
QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -1878,7 +1878,7 @@ ObjCInterfaceDecl *RewriteObjC::isSuperReceiver(Expr *recExpr) {
// struct objc_super { struct objc_object *receiver; struct objc_class *super; };
QualType RewriteObjC::getSuperStructType() {
if (!SuperStructDecl) {
- SuperStructDecl = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+ SuperStructDecl = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
SourceLocation(),
&Context->Idents.get("objc_super"), 0);
QualType FieldTypes[2];
@@ -1901,7 +1901,7 @@ QualType RewriteObjC::getSuperStructType() {
QualType RewriteObjC::getConstantStringStructType() {
if (!ConstantStringDecl) {
- ConstantStringDecl = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+ ConstantStringDecl = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
SourceLocation(),
&Context->Idents.get("__NSConstantStringImpl"), 0);
QualType FieldTypes[4];
@@ -3108,3 +3108,5 @@ void RewriteObjC::RewriteImplementations(std::string &Result) {
}
+
+
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index c404e4ff99..3e865f94c9 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -658,6 +658,15 @@ protected:
/// TagDecl - Represents the declaration of a struct/union/class/enum.
class TagDecl : public TypeDecl {
+public:
+ enum TagKind {
+ TK_struct,
+ TK_union,
+ TK_class,
+ TK_enum
+ };
+
+private:
/// IsDefinition - True if this is a definition ("struct foo {};"), false if
/// it is a declaration ("struct foo;").
bool IsDefinition : 1;
@@ -675,14 +684,29 @@ public:
}
const char *getKindName() const {
+ switch (getTagKind()) {
+ default: assert(0 && "Unknown TagKind!");
+ case TK_struct: return "struct";
+ case TK_union: return "union";
+ case TK_class: return "class";
+ case TK_enum: return "enum";
+ }
+ }
+
+ TagKind getTagKind() const {
switch (getKind()) {
default: assert(0 && "Unknown TagDecl!");
- case Struct: return "struct";
- case Union: return "union";
- case Class: return "class";
- case Enum: return "enum";
+ case Struct: case CXXStruct: return TK_struct;
+ case Union: case CXXUnion: return TK_union;
+ case Class: case CXXClass: return TK_class;
+ case Enum: return TK_enum;
}
}
+
+ bool isStruct() const { return getKind() == Struct || getKind() == CXXStruct;}
+ bool isClass() const { return getKind() == Class || getKind() == CXXClass; }
+ bool isUnion() const { return getKind() == Union || getKind() == CXXUnion; }
+ bool isEnum() const { return getKind() == Enum; }
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) {
@@ -777,7 +801,7 @@ protected:
}
public:
- static RecordDecl *Create(ASTContext &C, Kind DK, DeclContext *DC,
+ static RecordDecl *Create(ASTContext &C, TagKind TK, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl);
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 4c152f5adf..10ff6feec8 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -49,7 +49,7 @@ protected:
assert(classof(static_cast<Decl*>(this)) && "Invalid Kind!");
}
public:
- static CXXRecordDecl *Create(ASTContext &C, Kind DK, DeclContext *DC,
+ static CXXRecordDecl *Create(ASTContext &C, TagKind TK, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl);
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index d8e2c06fc0..11ca78a479 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -70,12 +70,12 @@ void ASTContext::PrintStats() const {
++NumTypeName;
else if (TagType *TT = dyn_cast<TagType>(T)) {
++NumTagged;
- switch (TT->getDecl()->getKind()) {
+ switch (TT->getDecl()->getTagKind()) {
default: assert(0 && "Unknown tagged type!");
- case Decl::Struct: ++NumTagStruct; break;
- case Decl::Union: ++NumTagUnion; break;
- case Decl::Class: ++NumTagClass; break;
- case Decl::Enum: ++NumTagEnum; break;
+ case TagDecl::TK_struct: ++NumTagStruct; break;
+ case TagDecl::TK_union: ++NumTagUnion; break;
+ case TagDecl::TK_class: ++NumTagClass; break;
+ case TagDecl::TK_enum: ++NumTagEnum; break;
}
} else if (isa<ObjCInterfaceType>(T))
++NumObjCInterfaces;
@@ -458,7 +458,7 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
NewEntry->InitializeLayout(D->getNumMembers());
bool StructIsPacked = D->getAttr<PackedAttr>();
- bool IsUnion = (D->getKind() == Decl::Union);
+ bool IsUnion = D->isUnion();
if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
NewEntry->SetAlignment(std::max(NewEntry->getAlignment(),
@@ -1214,7 +1214,7 @@ int ASTContext::getIntegerTypeOrder(QualType LHS, QualType RHS) {
QualType ASTContext::getCFConstantStringType() {
if (!CFConstantStringTypeDecl) {
CFConstantStringTypeDecl =
- RecordDecl::Create(*this, Decl::Struct, TUDecl, SourceLocation(),
+ RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
&Idents.get("NSConstantString"), 0);
QualType FieldTypes[4];
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index b5dba1029b..47334f53cc 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -101,10 +101,17 @@ EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
return new (Mem) EnumDecl(DC, L, Id, PrevDecl);
}
-RecordDecl *RecordDecl::Create(ASTContext &C, Kind DK, DeclContext *DC,
+RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl) {
void *Mem = C.getAllocator().Allocate<RecordDecl>();
+ Kind DK;
+ switch (TK) {
+ case TK_enum: assert(0 && "Enum TagKind passed for Record!");
+ case TK_struct: DK = Struct; break;
+ case TK_union: DK = Union; break;
+ case TK_class: DK = Class; break;
+ }
return new (Mem) RecordDecl(DK, DC, L, Id, PrevDecl);
}
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index c319191bae..b62ca58d72 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -26,9 +26,16 @@ CXXFieldDecl *CXXFieldDecl::Create(ASTContext &C, CXXRecordDecl *RD,
return new (Mem) CXXFieldDecl(RD, L, Id, T, BW);
}
-CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, Kind DK, DeclContext *DC,
+CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl) {
+ Kind DK;
+ switch (TK) {
+ case TK_enum: assert(0 && "Enum TagKind passed for Record!");
+ case TK_struct: DK = Struct; break;
+ case TK_union: DK = Union; break;
+ case TK_class: DK = Class; break;
+ }
void *Mem = C.getAllocator().Allocate<CXXRecordDecl>();
return new (Mem) CXXRecordDecl(DK, DC, L, Id, PrevDecl);
}
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index e561a1074c..7e09bb1ae3 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -63,8 +63,7 @@ bool Type::isDerivedType() const {
return true;
case Tagged: {
const TagType *TT = cast<TagType>(CanonicalType);
- const Decl::Kind Kind = TT->getDecl()->getKind();
- return Kind == Decl::Struct || Kind == Decl::Union;
+ return !TT->getDecl()->isEnum();
}
default:
return false;
@@ -73,19 +72,19 @@ bool Type::isDerivedType() const {
bool Type::isClassType() const {
if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType))
- if (RT->getDecl()->getKind() == Decl::Class)
+ if (RT->getDecl()->isClass())
return true;
return false;
}
bool Type::isStructureType() const {
if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType))
- if (RT->getDecl()->getKind() == Decl::Struct)
+ if (RT->getDecl()->isStruct())
return true;
return false;
}
bool Type::isUnionType() const {
if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType))
- if (RT->getDecl()->getKind() == Decl::Union)
+ if (RT->getDecl()->isUnion())
return true;
return false;
}
@@ -349,13 +348,13 @@ const RecordType *Type::getAsRecordType() const {
const RecordType *Type::getAsStructureType() const {
// If this is directly a structure type, return it.
if (const RecordType *RT = dyn_cast<RecordType>(this)) {
- if (RT->getDecl()->getKind() == Decl::Struct)
+ if (RT->getDecl()->isStruct())
return RT;
}
// If the canonical form of this type isn't the right kind, reject it.
if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
- if (RT->getDecl()->getKind() != Decl::Struct)
+ if (!RT->getDecl()->isStruct())
return 0;
// If this is a typedef for a structure type, strip the typedef off without
@@ -371,13 +370,13 @@ const RecordType *Type::getAsStructureType() const {
const RecordType *Type::getAsUnionType() const {
// If this is directly a union type, return it.
if (const RecordType *RT = dyn_cast<RecordType>(this)) {
- if (RT->getDecl()->getKind() == Decl::Union)
+ if (RT->getDecl()->isUnion())
return RT;
}
// If the canonical form of this type isn't the right kind, reject it.
if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
- if (RT->getDecl()->getKind() != Decl::Union)
+ if (!RT->getDecl()->isUnion())
return 0;
// If this is a typedef for a union type, strip the typedef off without
@@ -470,7 +469,7 @@ bool Type::isIntegerType() const {
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::LongLong;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- if (TT->getDecl()->getKind() == Decl::Enum)
+ if (TT->getDecl()->isEnum())
return true;
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isIntegerType();
@@ -484,7 +483,7 @@ bool Type::isIntegralType() const {
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::LongLong;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- if (TT->getDecl()->getKind() == Decl::Enum)
+ if (TT->getDecl()->isEnum())
return true;
if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
return ASQT->getBaseType()->isIntegralType();
@@ -493,7 +492,7 @@ bool Type::isIntegralType() const {
bool Type::isEnumeralType() const {
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- return TT->getDecl()->getKind() == Decl::Enum;
+ return TT->getDecl()->isEnum();
if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
return ASQT->getBaseType()->isEnumeralType();
return false;
@@ -587,7 +586,7 @@ bool Type::isRealType() const {
return BT->getKind() >= BuiltinType::Bool &&
BT->getKind() <= BuiltinType::LongDouble;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
- return TT->getDecl()->getKind() == Decl::Enum;
+ return TT->getDecl()->isEnum();
if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isRealType();
if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
@@ -611,7 +610,7 @@ bool Type::isScalarType() const {
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
return BT->getKind() != BuiltinType::Void;
if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
- if (TT->getDecl()->getKind() == Decl::Enum)
+ if (TT->getDecl()->isEnum())
return true;
return false;
}
@@ -623,7 +622,7 @@ bool Type::isScalarType() const {
bool Type::isAggregateType() const {
if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
- if (TT->getDecl()->getKind() == Decl::Struct)
+ if (TT->getDecl()->isStruct())
return true;
return false;
}
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index bab5a21a6a..2f8784f7d5 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -375,7 +375,7 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
// Okay, this is a definition of a type. Compile the implementation now.
- if (TD->getKind() == Decl::Enum) {
+ if (TD->isEnum()) {
// Don't bother storing enums in TagDeclTypes.
return ConvertTypeRecursive(cast<EnumDecl>(TD)->getIntegerType());
}
@@ -391,7 +391,7 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
const llvm::Type *ResultType;
const RecordDecl *RD = cast<const RecordDecl>(TD);
- if (TD->getKind() == Decl::Struct || TD->getKind() == Decl::Class) {
+ if (TD->isStruct() || TD->isClass()) {
// Layout fields.
RecordOrganizer RO(*this, *RD);
@@ -402,7 +402,7 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
RO.getPaddingFields());
ResultType = RO.getLLVMType();
- } else if (TD->getKind() == Decl::Union) {
+ } else if (TD->isUnion()) {
// Just use the largest element of the union, breaking ties with the
// highest aligned member.
if (RD->getNumMembers() != 0) {
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 980717f15e..3861d04bf0 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -57,7 +57,7 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
PushOnScopeChains(IDecl, TUScope);
// Synthesize "typedef struct objc_selector *SEL;"
- RecordDecl *SelTag = RecordDecl::Create(Context, Decl::Struct, CurContext,
+ RecordDecl *SelTag = RecordDecl::Create(Context, TagDecl::TK_struct, CurContext,
SourceLocation(),
&Context.Idents.get("objc_selector"),
0);
@@ -98,7 +98,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer)
TranslationUnitDecl *TUDecl = Context.getTranslationUnitDecl();
// Synthesize "typedef struct objc_class *Class;"
- RecordDecl *ClassTag = RecordDecl::Create(Context, Decl::Struct,
+ RecordDecl *ClassTag = RecordDecl::Create(Context, TagDecl::TK_struct,
TUDecl,
SourceLocation(),
&IT.get("objc_class"), 0);
@@ -117,7 +117,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer)
// Synthesize "typedef struct objc_object { Class isa; } *id;"
RecordDecl *ObjectTag =
- RecordDecl::Create(Context, Decl::Struct, TUDecl,
+ RecordDecl::Create(Context, TagDecl::TK_struct, TUDecl,
SourceLocation(),
&IT.get("objc_object"), 0);
FieldDecl *IsaDecl = FieldDecl::Create(Context, SourceLocation(),
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 1b1e636a76..ba005b2c60 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1637,13 +1637,13 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK,
assert((Name != 0 || TK == TK_Definition) &&
"Nameless record must be a definition!");
- Decl::Kind Kind;
+ TagDecl::TagKind Kind;
switch (TagType) {
default: assert(0 && "Unknown tag type!");
- case DeclSpec::TST_struct: Kind = Decl::Struct; break;
- case DeclSpec::TST_union: Kind = Decl::Union; break;
- case DeclSpec::TST_class: Kind = Decl::Class; break;
- case DeclSpec::TST_enum: Kind = Decl::Enum; break;
+ case DeclSpec::TST_struct: Kind = TagDecl::TK_struct; break;
+ case DeclSpec::TST_union: Kind = TagDecl::TK_union; break;
+ case DeclSpec::TST_class: Kind = TagDecl::TK_class; break;
+ case DeclSpec::TST_enum: Kind = TagDecl::TK_enum; break;
}
// If this is a named struct, check to see if there was a previous forward
@@ -1662,7 +1662,7 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK,
IdResolver.isDeclInScope(PrevDecl, CurContext, S)) {
// Make sure that this wasn't declared as an enum and now used as a struct
// or something similar.
- if (PrevDecl->getKind() != Kind) {
+ if (PrevTagDecl->getTagKind() != Kind) {
Diag(KWLoc, diag::err_use_with_wrong_tag, Name->getName());
Diag(PrevDecl->getLocation(), diag::err_previous_use);
}
@@ -1705,22 +1705,18 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK,
// Otherwise, if this is the first time we've seen this tag, create the decl.
TagDecl *New;
- switch (Kind) {
- default: assert(0 && "Unknown tag kind!");
- case Decl::Enum:
+ if (Kind == TagDecl::TK_enum) {
// FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
// enum X { A, B, C } D; D should chain to X.
New = EnumDecl::Create(Context, CurContext, Loc, Name, 0);
// If this is an undefined enum, warn.
if (TK != TK_Definition) Diag(Loc, diag::ext_forward_ref_enum);
- break;
- case Decl::Union:
- case Decl::Struct:
- case Decl::Class:
+ } else {
+ // struct/union/class
+
// FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
// struct X { int A; } D; D should chain to X.
New = RecordDecl::Create(Context, Kind, CurContext, Loc, Name, 0);
- break;
}
// If this has an identifier, add it to the scope stack.
@@ -1959,7 +1955,7 @@ void Sema::ActOnFields(Scope* S,
continue;
}
if (i != NumFields-1 || // ... that the last member ...
- Record->getKind() != Decl::Struct || // ... of a structure ...
+ !Record->isStruct() || // ... of a structure ...
!FDTy->isArrayType()) { //... may have incomplete array type.
Diag(FD->getLocation(), diag::err_field_incomplete, FD->getName());
FD->setInvalidDecl();
@@ -1982,7 +1978,7 @@ void Sema::ActOnFields(Scope* S,
if (const RecordType *FDTTy = FDTy->getAsRecordType()) {
if (FDTTy->getDecl()->hasFlexibleArrayMember()) {
// If this is a member of a union, then entire union becomes "flexible".
- if (Record && Record->getKind() == Decl::Union) {
+ if (Record && Record->isUnion()) {
Record->setHasFlexibleArrayMember(true);
} else {
// If this is a struct/class and this is not the last element, reject
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index a7135ea4cf..45affcab16 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -285,7 +285,7 @@ void Sema::ActOnBaseSpecifier(DeclTy *classdecl, SourceRange SpecifierRange,
// C++ [class.union]p1:
// A union shall not have base classes.
- if (Decl->getKind() == Decl::Union) {
+ if (Decl->isUnion()) {
Diag(Decl->getLocation(), diag::err_base_clause_on_union,
SpecifierRange);
Decl->setInvalidDecl();
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index e2377e18ba..0078cc149c 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -42,7 +42,7 @@ int InitListChecker::numStructUnionElements(QualType DeclType) {
for (int i = 0; i < structDecl->getNumMembers(); i++)
if (structDecl->getMember(i)->getIdentifier())
++InitializableMembers;
- if (structDecl->getKind() == Decl::Union)
+ if (structDecl->isUnion())
return std::min(InitializableMembers, 1);
return InitializableMembers - structDecl->hasFlexibleArrayMember();
}