-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
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 980717f..3861d04 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -57,7 +57,7 @@
   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 @@
     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 @@
     
     // 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 1b1e636..ba005b2 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1637,13 +1637,13 @@
   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 @@
           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 @@
   
   // 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 @@
         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 @@
     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 a7135ea..45affca 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -285,7 +285,7 @@
 
   // 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 e2377e1..0078cc1 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -42,7 +42,7 @@
   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();
 }