Simplify handling of struct/union/class tags.
Instead of using two sets of Decl kinds (Struct/Union/Class and CXXStruct/CXXUnion/CXXClass), use one 'Record' and one 'CXXRecord' Decl kind and make tag kind a property of TagDecl.
Cleans up the code a bit and better reflects that Decl class structure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57541 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 382b9eb..3713776 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -221,9 +221,9 @@
// RecordDecl Implementation
//===----------------------------------------------------------------------===//
-RecordDecl::RecordDecl(Kind DK, DeclContext *DC, SourceLocation L,
+RecordDecl::RecordDecl(Kind DK, TagKind TK, DeclContext *DC, SourceLocation L,
IdentifierInfo *Id)
-: TagDecl(DK, DC, L, Id, 0) {
+: TagDecl(DK, TK, DC, L, Id, 0) {
HasFlexibleArrayMember = false;
assert(classof(static_cast<Decl*>(this)) && "Invalid Kind!");
@@ -236,16 +236,7 @@
RecordDecl* PrevDecl) {
void *Mem = C.getAllocator().Allocate<RecordDecl>();
- Kind DK;
- switch (TK) {
- default: assert(0 && "Invalid TagKind!");
- 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;
- }
-
- RecordDecl* R = new (Mem) RecordDecl(DK, DC, L, Id);
+ RecordDecl* R = new (Mem) RecordDecl(Record, TK, DC, L, Id);
C.getTypeDeclType(R, PrevDecl);
return R;
}